Can anyone tell me how to detect when a users session has exipred in asp?
I want to redirect users to a logged out page once the session has expired
Thanks
Sp
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the Session_End() function in your global.asax file. Please see here for more info
SO – Session End
EDIT: Nope, that probably won’t do it. See comments below.
If you must redirect on a session expiration, would something like this do the trick for you?
EDIT 2: Caveat, this can get tricky if you have AJAX stuff going on.
I have seen examples where people will put this in the page_load of a base page and inheirit all of your .aspx pages from this base page. This prevents you from having to add this code for every single page that you have.
Why won’t the first method work (Session_End)? This is a function called internally on the server when a session ends. As such, there is no associated request/response to redirect or transfer. I.e., this function could be called by the server 20 minutes after you close the browswer.