Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
Hi,

In my project, I have stored some town name in session, once session is expired I want to redirect the page based on town name which I stored in expired session. Can any one help me how to achieve this.


Thanks,
Baskar G
Posted
Updated 3-Aug-15 4:10am
v2

1 solution

You can't access the session after it has expired. You could store the data in a cookie, and if the session is a new session (ie the old one has expired) and the cookie exists, then you can redirect based on the cookie value.

Google for how to detect if it's a new session, and also how to read\write cookies if you don't know how to do those things.
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 3-Aug-15 10:09am    
5ed, good answer.

But, instead of Googling for a solution, it would be better to check whether session variable exists or not. if(Session["variable"] == null) { /* session expired or started now */ }. ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900