Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Global.asa - Session_OnEnd Question ..

Reply
Thread Tools

Global.asa - Session_OnEnd Question ..

 
 
MostlyH2O
Guest
Posts: n/a
 
      07-28-2003
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



 
Reply With Quote
 
 
 
 
Roy in
Guest
Posts: n/a
 
      07-28-2003
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

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:...
> I suggest you do something a little different, like:
>
> Sub session_onstart()
> session("active") = true
> End Sub
>
> And then use something like
> If Not(session("active")) Then response.redirect "/mylogin.asp"
>
>
> See here for the reasons.
> http://www.aspfaq.com/2078
>
> When the session ends, the browser could be closed, and the user's

computer
> may even be turned off, unplugged, and thrown away. How could you do a
> redirect then?
>
> Ray at home
>
>
> --
> Will trade ASP help for SQL Server help
>
>
> "MostlyH2O" <> wrote in

message
> news:XU1Va.172194$. com...
> > 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
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
 
Roy in
Guest
Posts: n/a
 
      07-28-2003
Actually what I meant to say is that Ray was right, but you have to read the
Entire article- just like I keep saying.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:...
> I suggest you do something a little different, like:
>
> Sub session_onstart()
> session("active") = true
> End Sub
>
> And then use something like
> If Not(session("active")) Then response.redirect "/mylogin.asp"
>
>
> See here for the reasons.
> http://www.aspfaq.com/2078
>
> When the session ends, the browser could be closed, and the user's

computer
> may even be turned off, unplugged, and thrown away. How could you do a
> redirect then?
>
> Ray at home
>
>
> --
> Will trade ASP help for SQL Server help
>
>
> "MostlyH2O" <> wrote in

message
> news:XU1Va.172194$. com...
> > 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
> >
> >
> >

>
>



 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      07-28-2003
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 <%=H.E.Double Toothpicks $>" <> wrote in
message news:ef$...
> Actually what I meant to say is that Ray was right, but you have to read

the
> Entire article- just like I keep saying.
>
> "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
> news:...
> > I sugge



 
Reply With Quote
 
TomB
Guest
Posts: n/a
 
      07-28-2003
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 <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:...
> 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 <%=H.E.Double Toothpicks $>" <> wrote in
> message news:ef$...
> > Actually what I meant to say is that Ray was right, but you have to read

> the
> > Entire article- just like I keep saying.
> >
> > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
> > news:...
> > > I sugge

>
>



 
Reply With Quote
 
Mark Hastings
Guest
Posts: n/a
 
      07-28-2003
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%>">her e</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


 
Reply With Quote
 
MostlyH2O
Guest
Posts: n/a
 
      07-28-2003
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
YET ANOTHER QUESTION ON SESSION TIMEOUT AND SESSION_ONEND() HolaGoogle Javascript 4 11-20-2003 08:45 PM
session_onend event not firing rob ASP .Net 6 08-28-2003 09:43 AM
Session_OnEnd not fired in SQL Server mode steve ASP .Net 0 08-25-2003 12:53 AM
Session variables and Session_OnEnd Hans Kesting ASP .Net 4 08-19-2003 09:48 AM
my session_onend is not working anand ASP .Net 4 07-22-2003 04:47 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57