Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session timeout event?

Status
Not open for further replies.

efrost2

Programmer
Jul 18, 2001
50
US
Does an event get fired when session variable times out?
I would like to have the browser load another page when session times out.
Thanks
 
You're not going to be able to do this with the global.asa file because the user could close their browser window and go to lunch without the session expiring.

What you want to do is create a session variable at the time the user logs into your application. Something like this.

Code:
Session("loggedin") = "Yes"

Then write the following lines into an include file, name the file checksession.inc and place the include file on your webserver.
Code:
<%
IF Session(&quot;loggedin&quot;) <> &quot;Yes&quot; THEN
  Response.Redirect &quot;somepage.asp&quot;
END IF
%>

Then the top of all of your ASP pages would look something like this.
Code:
<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>
<!-- #include file=&quot;checksession.inc&quot; -->

You must have the Response.Buffer = True statement before the include file or the Redirect won't work.

Then when someone tries to access any of your pages without a valid session, it'll redirect them to a page of your choice.

Hope this helps..

ToddWW :)
 
Yes, I got this far. But what I want to do is have a new page load as soon as the session times out - even if the user does not try to access a protected page.
Thanks
 
Nope. The server can't do anything to the browser without the browser first making a request.

Sorry :-(

ToddWW
 
Maybe you can do the following:

function window_onload() {
window.setInterval(&quot;Redir()&quot;,60000);
}
function Redir() {
window.location.href=&quot;somepage.asp&quot;;
}
.
.
.
.
<BODY LANGUAGE=javascript onload=&quot;return window_onload()&quot;>


The function 'Redir()' will be executed after 60 seconds the page was loaded.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top