PDA

Click to See Complete Forum and Search --> : Session End


Fishcake
Oct 16th, 2003, 10:52 AM
When a session timeouts on my site i want the user to be redirected back to the homepage, telling them that the session has expired please log in again, blah blah.

I've put a breakpoint on the session_end sub in global.aspx and this is firing once the session timeouts, how do i then make the broswer point to my SessionExpire.aspx page?

Cheers.

Lethal
Oct 16th, 2003, 11:14 AM
You could use a Response.Redirect() to send the user to your page. Also, look into Forms Authentication and make sure you are not trying to re-invent the wheel here.

Fishcake
Oct 17th, 2003, 03:17 AM
Response.redirect won't work from global.aspx, I'll try and have a look at Forms Authentication but i don't really have time now to make any major changes.

Fishcake
Oct 17th, 2003, 04:05 AM
Forms Authentication looks useful, although i have already invented the wheel, still next time i'll use it.

But is there a way i can redirect to a page from global.aspx? Am i using response.redirect wrong in that context?
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
Response.Redirect("sessexpire.aspx")
End Sub

Lethal
Oct 17th, 2003, 08:04 AM
Originally posted by Fishcake
Response.redirect won't work from global.aspx, I'll try and have a look at Forms Authentication but i don't really have time now to make any major changes.

It wont work in some instances where the session has not yet be initiated (Application_OnStart), but you have access to it in the session events. I would really re-think what you are doing and use Forms Authentication.

svatasoiu
Oct 17th, 2003, 08:39 AM
If you are planning to do not keep the sessions on process, do not count on session_end, it will not work if you keep the sessions on sql or on state server

Lethal
Oct 17th, 2003, 08:49 AM
Not to mention Session_OnEnd is a little buggy, where it does not always fire off..

Fishcake
Oct 17th, 2003, 08:58 AM
The Session_onEnd event seems to fire ok, I've set the session.timeout to 1 just for testing and it fires every minute.

I've put a breakpoint on response.redirect("sessexpire.aspx") but after this line whilst debugging it switches back to the browser window but nothing happens.

I would've used form authentication but am now very short on time, my project is about finished and this is the only thing i can't get working. How long would you estimate it would take me to implement authentication? is it a quick and painless process?

Cheers.