Click to See Complete Forum and Search --> : Sub Session_OnEnd in global.asa problems!!


nyfiken
07-22-2005, 06:30 AM
Hi!

This is the code in my global.asa file. I want the file "end.asp" to start when a the sessions timeout is 1 minute, just to see if it works. But i dosn't work.

Does the Sub Session_OnEnd only activates when the browser is closed down or? In the end, I want a page to open when the sessions is timeout to inform visitor that their session is closed to prevent problems with all sessions variables writing to files and other things.

Could it be solved in anoterh way?

<script language="vbscript" runat="server">
Sub Session_OnStart
Session.TimeOut = 1
response.redirect "start.asp"
End Sub
Sub Session_OnEnd
response.redirect "end.asp"
End Sub
</script>

Thanks

buntine
07-22-2005, 07:12 AM
Unfortunately, the Response and Request objects are not available in this context as no actual request has been made. Furthermore, the concept will not withstand because server-side events cannot be triggered from the client-side.

Considering the timeout length is hardcoded, you could devise a workaround, such as a JavaScript timeout. This will acheive the desired result.

Regards.

nyfiken
07-22-2005, 11:20 AM
Thanks for your replay, but i'm suprised it won't work! What's the use of Sub Session_OnEnd then?

Dosen't the code in the global.asa file "know" when the session.timeout is true? I thougt a file could be open with respone.redirect when session is timeout with the global.asa file?!

Would it be better with a "secret" Javascript function in a frame that after x minutes opens a new page then?

Have a nice weekend!

nyfiken

buntine
07-22-2005, 08:44 PM
One key use of the Session_OnEnd routine is to clean up the datastore. You may be storing the number of actve users in a database or something, when the session is cleared, you can alter the database from Session_OnEnd. Normally, Session_OnEnd is called after the user has left the application, so trying to redirect them won't prove too successful. ;)

The JavaScript function can be placed straight into the page. But, yeah, your idea is the same as what I had in mind.

Regards.