mike55 Posted October 12, 2006 Posted October 12, 2006 I am trying to set the timeout of my site to 20 minutes, however I cannot seem to get it to work. Some pages will timeout after about 5 minutes, others will do so after 60 minutes. Here is what I have done so far: 1. I have set the timeout value in the web.config file: <authentication mode="Forms"> <forms name="www.abc.eu" loginUrl="Index.aspx" timeout="20" /> </authentication> 2. I went to IIS, selected Virtual Directory and clicked on the Configuration button. In the Options tab, I set the session timeout value to 20 minutes and left the ASP Script timeout at 90 seconds. 3. Still in IIS, I selected the Http Headers tab and have selected the "Expire after:" radio button and I have set that to 1 day (Should I set it to longer). 4. Next I went to the ASP.NET tab, and clicked the Edit Configuration button. I selected the Authentication tab, and confirmed that my cookie timeout is set to 20. The tickbox Enable Sliding Expiration is also ticked. 5. I then selected the State Management tab. Here I see that the Session State mode is: InProc, the Cookieless mode is: UseCookies and Session timeout is set to: 20 minutes. Can anyone suggest what I have done wrong? or why I cannot control the session timeout. Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
mike55 Posted October 12, 2006 Author Posted October 12, 2006 Potential Solution Ok, I am after finding a beautiful little fix. Simply add the following javascript to your pages. var g_nSessionTimeout = 20; // time out in minutes var g_nSessionWarn = 0; //when to warn ** g_nSessionTimeout - g_nSessionWarn = displayed time when warning is displayed var g_nStopMinutes = ( g_nSessionTimeout - 1 ); var g_nStopSeconds = 59; function stop() { clearTimeout(tick); } function sessionTimer() { if ( g_nSessionTimeout != 0 ) { if ( g_nStopSeconds == 0 ) { g_nStopSeconds = 59; g_nStopMinutes = ( g_nStopMinutes - 1 ); if ( g_nStopMinutes == ( ( g_nSessionTimeout - g_nSessionWarn) - 1 ) ) window.alert('For security reasons your session will \n time out in ' + (g_nSessionTimeout - g_nSessionWarn) + ' minutes if there is no activity.'); } else g_nStopSeconds = (g_nStopSeconds - 1); if (g_nStopSeconds <= 9) g_nStopSeconds = "0" + g_nStopSeconds; window.status = ('Your Session Will Time Out In ' + g_nStopMinutes + ':' + g_nStopSeconds); if ( ( g_nStopMinutes == 0) && ( g_nStopSeconds == 0) ) { window.status = 'Your sesson has been disconnected'; var url = location.href; arg = ""; arg = arg + "/default2.aspx"; url1 = url.substring(0,url.lastIndexOf(".asp")+1); top.location.href = url1.substring(0,url1.lastIndexOf("/")+1)+arg; } else setTimeout( "sessionTimer()",1000 ); } } sessionTimer(); It displays a message at the bottom of your page in the explorers bottom bar, that tells you how long you have left till you are logged out. Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.