|
-
Jul 6th, 2001, 09:23 AM
#1
Thread Starter
Member
Automatic Log Out
Howzit!!
I am maintaining a Web page where the User needs to be logged in I then lock that user account so that only one account can be used at a time, Now if the User forgets to logg out or leaves the system un attented for a set amount of time I would like to Logg him out automatically and redirect the user to a page, I had a go at it and here's my code, could you please help me out??
********************
<OBJECT RUNAT=Server SCOPE=Session ID=MyInfo PROGID="MSWC.MyInfo"></OBJECT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
If isEmpty(Application("counter")) Then
Application("counter") = 0
Application("count") = 0
else
Application("counter") = Application("counter") + 1
Application("count") = Application("count") + 1
end If
Session.TimeOut=5
End Sub
Sub Session_onEnd
Application("count") = Application("count") - 1
dim cnMain
dim lcDate
dim lcTime
dim sSQL
lcdate = FormatDateTime(Now(),vbShortDate)
sday = mid(lcdate,instr(lcdate,"/")+1,instr(mid(lcdate,instr(lcdate,"/")+1),"/")-1)
if len(sday) < 2 then
sday = "0" & sday
end if
smonth = mid(lcdate,1,instr(lcdate,"/")-1)
if len(smonth) < 2 then
smonth = "0" & smonth
end if
syear = "20" & right(lcdate,2)
lcdate = sday & "/" & smonth & "/" & syear
lcTime = FormatDateTime(Now, vbLongTime)
sSQL = "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=MyServer;Initial Catalog=MyCat;User ID=Guest;Password=;ConnectionTimeout=10;"
Set cnMain = Server.CreateObject("ADODB.Connection")
cnMain.Mode = abModeReadWrite
cnMain.ConnectionString = sSQL
cnMain.open
sTime = FormatDateTime(time,vbShortTime)
conn.Execute("INSERT INTO AuditTrail (Audit_UID, Audit_Date, Audit_Time, Audit_Flag, Audit_InOut, Audit_Reason) Values ('" & Session("sUID") & "','" & lcdate & "','" & lctime & "','0','In','Session Time Out')")
conn.Execute("Update Users Set User_Locked = 0 WHERE User_UID = '" & Session("sUID") & "' AND User_Comp_UID = '" & Session("sCID") & "'")
cnMain.Close
Response.Redirect "http://www.newsclip.co.za/asp/session.asp"
End Sub
</Script>
********************
Thanks in Advance!
-
Jul 6th, 2001, 09:32 AM
#2
So whats the problem? I dont think you can redirect users using the global.asa thou :/
-
Jul 6th, 2001, 09:56 AM
#3
you are right, you cant response anything in a global.asa chenko.
Besides resonse.redirect in a Session_ONEnd makes absolutly no sense at all.
plus. Your code appears that it should work besides the response.redirect, but also take note, Session onEnd will NOT fire off until the Session expires, not when they leave the page or close their browser
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|