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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions and timeouts

Status
Not open for further replies.

Maldini

Technical User
Nov 10, 2002
55
0
0
GB
Is there a way to catch session timeouts, or to redirect users to another page on timeout?

I've googled a bit, and I hope I'm not mistaken, the Global.asa file seems to offer something like this, but it doesn't work for me.
I've got:

<script language="vbscript" runat="server">

Sub Session_OnStart
Session.Timeout = 20
End Sub

Sub Session_OnEnd
Response.Redirect("Main.asp")
End Sub

</script>

However, I've placed it into my application directory (the root of the app), and yet nothing happens. I've tried shortening the timeout time, and yet it doesn't redirect for some strange reason.

Have I gone wrong somewhere?

Thanks.
Maldini.
 
By the way, I don't own the server, only have an account on it for the application. Can I still do this, or is this the problem?
Thanks again.
 
i believe that before the session times out you need to set it first(not sure cause i don't use it in the global.asa

try this:
set the timeout to 1 (on the global.asa)

then create 2 pages two pages
test.asp
test2.asp

on test.asp place this script
Code:
<%
session("foo")="bar"
response.write "<a href=""test2.asp"">go to test2.asp</a>
%>

on test2.asp place this script
Code:
<%
if session("foo")<>"" then 
response.write "your session is: "& session("foo")
else
response.write "you session has timed out"
end if
%>
now go to test.asp and click the link it should say "your session is: bar" then wait 3 mins and hit refresh(from within the test2.asp page) it should now say "your session has timed out"
 
Well, I have set a number of sessions in fact, the one to store logged in details is the one I've been testing the global.asa with.
When you say you don't use global.asa, do you include the Sub Session_OnEnd within the actual asp file or is it all manually handled by checking session content?

Thanks again.
Maldini
 
i manually check with an include

ex.

Code:
if request("logout")="t" then
session("status")="out"
end if
If session("status")<>"in" then
response.Redirect("index.asp")
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top