Hi,
Is there a way to set how long a session variable persists before it is destroyed? I use forms based authentication on my site, but some events are based on particular session variables, and often times the session variable will be destroyed if the user leaves the session idle for a few minutes. Can I configure my site so that session variables stick around until the forms authentication session is over? Or, is it possible to set an event that triggers when the session state expires or when the session variables are destroyed that redirects to the login page?
![]() |
0 |
![]() |
you can set the session timout in web.config. <sessionState timeout="15"/> the value is in minutes, so its 15 min.
OR you can also clear the session state when redirects to logout or any other page by calling Session.Clear() function.
![]() |
0 |
![]() |
ppalubinski:
Can I configure my site so that session variables stick around until the forms authentication session is over?Make sure authentication timeout and session timeout values are same in webconfig..
<sessionState cookieless="UseDeviceProfile" timeout="40" /> <authentication mode="Forms"> <forms name="MyAuthCookie" loginUrl="login.aspx" defaultUrl="Default.aspx" timeout="40" slidingExpiration="true" cookieless="UseDeviceProfile" path="/" protection="All" /> </authentication>Also check session timeout value in IIS.
My Blog
"Don't be afraid to be wrong; otherwise you'll never be right."
![]() |
0 |
![]() |
Thanks everyone! Looks like that did the trick. I appreciate your help.
![]() |
0 |
![]() |