Global.asa - Session_OnEnd Question ..

M

MostlyH2O

Hi Folks,

I'm having a hard time getting my Session_OnEnd event to fire in my
global.asa.
Here's what I have:

<SCRIPT LANGUAGE=VBSCRIPT RUNAT=Server>
SUB Session_OnStart
Session.TimeOut = 30
END SUB

Sub Session_OnEnd
Response.Redirect("http://mydomain.com/mylogin.asp")
End Sub
</SCRIPT>

I made a simple page to call the session.abandon - to test the OnEnd event.
But it doesn't fire. I have set the session.timeout to 1 and also waited for
the default 20 to pass. I just can't get that redirect to occur when the
session ends.

I know the global.asa is set up properly, because the OnStart event WILL
fire if I move my redirect statement to the SUB Session_OnStart routine.

Thanks very much for any help.

Clear Skies,
Jack Coletti
 
R

Roy in

But obvously this guy's browser was not closed in this case, because he was
testing to see if the redirection would occur.
http://www.aspfaq.com/2078

this article say that there is a bug, not that his test should fail because
his computer might be turned off.

Ray is at <%=sLocation%>" but the lights are off
 
R

Roy in

Actually what I meant to say is that Ray was right, but you have to read the
Entire article- just like I keep saying.
 
R

Ray at

It is late on a Sunday night (in the easter time zone anyway). You should
not be drunk. ;]

Ray at home
 
T

TomB

Ah yes the easter time zone, where every morning chocolate eggs are found
scattered throughout the home.

If the Session has ended, then the user hasn't requested anything from the
server. Since the server can't send anything to the client without a
request, you won't be able to redirect anywhere.

If the user was browsing around your site then his Session("Active") ="true"
as set in Session_OnStart. Then he goes for a nap and his session times
out. As soon as he clicks on a link or refreshes his screen, his
Session("Active") will again be set to "true" as a new session will have
begun.
The response.redirect will never be called in the Session_OnEnd.

If the goal is merely to ensure someone is logged in and their session is
active. It would be more logical to set the Session("Active")=true in the
login processing page, then checking that it's still valid at the top of
every page--a good job for an #include.




Ray at said:
It is late on a Sunday night (in the easter time zone anyway). You should
not be drunk. ;]

Ray at home

--
Will trade ASP help for SQL Server help


Roy in said:
Actually what I meant to say is that Ray was right, but you have to read the
Entire article- just like I keep saying.
 
M

Mark Hastings

I'm going to assume what you are trying to accomplish is to require the user
to log back in after a period of inactivity. As was pointed out in previous
posts, this can not be accomplished using the Session_OnEnd sub in the
global.asa file.

The method I use for this is to simply use a meta element in HTML and
redirect the browser after a period of time equivalent to my session timeout
on the server. I redirect to a page informing the user that their session
has timed out.

On the page I want to timeout, I put:
<% strThisPageURL = "http://" & Request.ServerVariables("SERVER_NAME") &
Request.ServerVariables("URL")
<meta http-equiv="refresh" content="1200; URL=<% Response.Write "http://" &
Request.ServerVariables("SERVER_NAME") & "/ExpiredLogIn.asp?U=" &
strThisPageURL %>">

The page ExpiredLogIn.asp is:
<html>
<head>
<title>Log-In Expired</title>
</head>
<%If Not IsEmpty(Request.QueryString("U")) Then strPreviousPageURL =
Request.QueryString("U")%>
<body>
<p align="center">&nbsp;</p>
<h3 align="center">Your Log-in has expired due to inactivity.</h3>
<h3 align="center">If you wish to log-in again, click <a
href="LogInForm.asp?U=<%=strPreviousPageURL%>">here</a>.</h3>
</body>
</html>

And in my login page, it looks for the QueryString for the URL of the timed
out page and redirects there after a successful login.

HTH
Mark
 
M

MostlyH2O

Thanks for all the help, good people.

Yes, I would have toiled for days trying to get the global.asa to redirect
the user to the login page after the session timed out. And, I *was* trying
to avoid checking the session state at the top of each of the 47 pages that
make up my utility.

Thanks for setting me straight :)

Clear Skies,
Jack Coletti
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Global.asa 5
Global.asa and Session_OnEnd 1
Session.Timeout in global.asa? 1
global.asa @ Session_OnEnd 1
Global.asa Session_OnEnd 3
Global.asa 2
General global.asa failure 3
Global.asa and Session_OnEnd 4

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top