Results 1 to 2 of 2

Thread: AutoLogoff

  1. #1 Guest

    Default AutoLogoff

    I want to Implement an automatic log off from our system after a pre-set period of inactivity (1 hour). If allotted time does expire and the user attempts to access the system, he/she would see a message box appear advising them that their session has expired and that they need to log back into the system. <BR>Please help me I am new to web developments.<BR><BR>I have tried the following and its doesn&#039t work<BR><BR>in my global.asa file I added the following<BR><BR>Sub Session_OnStart<BR>&#039**Put your code here **<BR> session("Authenticated") = Session.SessionID<BR> session.Timeout = 2<BR>End Sub<BR><BR>And than added the followinf testing line in one of my page<BR><BR>If (Session("Authenticated") &#060;&#062; Session.SessionID) Then<BR><BR>response.write "INSIDE Session(Authenticated )--&#062;" & Session("Authenticated")<BR>response.write "INSIDE Session.SessionID--&#062;" & Session.SessionID<BR><BR><BR><BR> Session("RequestedURL") = "http://" & _<BR> Request.ServerVariables("SERVER_NAME") & _<BR> Request.ServerVariables("SCRIPT_NAME")<BR><BR> Temp = Request.ServerVariables("QUERY_STRING")<BR> If (Not(ISNull(Temp)) AND Temp &#060;&#062; "") Then<BR> Session("RequestedURL") = Session("RequestedURL") & _<BR> "?" & Temp<BR> End If<BR> Response.Write "&#060;Script Language=JavaScript&#062;" & vbcrlf<BR> Response.Write "alert(""User Session of GB2000 has expired due to inactivity. Please re-enter password to access the system"");" & vbcrlf<BR> Response.Write "&#060;/SCRIPT&#062;" & vbcrlf<BR> Response.Redirect("main.htm")<BR>End If<BR>-<BR>-<BR>-<BR>-<BR>&#060;html&#062;<BR>&#060;head&#062;<BR>&#060; script LANGUAGE="javascript" src="Include/JSConstants.js"&#062;&#060;/script&#062;<BR>&#060;SCRIPT LANGUAGE="JAVASCRIPT"&#062;<BR><BR>window.setInter val("f_RefreshMe()",60000)<BR><BR>function f_RefreshMe()<BR>{<BR> document.location = "search.asp"; <BR>}<BR>-<BR>-<BR>--<BR><BR>It refresh the page at specfied time but the sessionid never change and due to same id it never goes inside if statement..<BR><BR>Please help me I am New to ASP<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: AutoLogoff

    What I do is keep a field in my database called "LastTrack" which tracks their last activity. Whenever somebody logs in (this is instead of an automated task), I call a script which checks for inactive users by checking the DateDiff("n", LastTrack, Now). If it is greater than 60 minutes, I run a script to log that user off.<BR><BR>Now if you could get this to work with an automated task, it would be even better. But depending on the traffic volume of your site, calling the script every time the login script is called may be just fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts