Session timeout

Posted on 2006-04-11
Medium Priority
Last Modified: 2011-10-03

Where can I exactly set session timeout?  What is the difference in setting the timeout in web.config, global.asax or FormAuthenticationTicket etc.?

Is it possible to show remaining time for expiring session in pages?

Question by:ayha1999
  • 2

Assisted Solution

fizch earned 200 total points
ID: 16428446
You would want to set the session timeout in the web.config file. Unfortunately, the only way to countdown the remaining time to expiration would be to build your own control. You know that everytime the page is sent, your expiration restarts. So however long you have to timeout set for, you would count back from there on page load.

Assisted Solution

daniel_balla earned 200 total points
ID: 16429139
> Is it possible to show remaining time for expiring session in pages?
that would always be the same, equal to the session timeout (as fizch stated it is counted from the last request onwards)
About setting it, you could set it in machine.config (therefore applied to ALL sites running on that server), then you can set it in web.config and you can also set it programatically using the TimeOut property of the HttpSessionState object (so something like Session.TimeOut = 19)

Expert Comment

ID: 16429155
you could do a javascript counter that would start from the session timeout and show on page. that would give the user a fair estimation.
LVL 12

Accepted Solution

bsdotnet earned 600 total points
ID: 16434335
simple Javascript:

<script language="JavaScript">
        var StartTime  = "";
        var varTimeout = 15;
        function Timer() {
            if(StartTime=="") StartTime = new Date().getTime();
            var newTime = new Date();
            newTime.setTime(60000 * varTimeout - newTime.getTime() + StartTime);
            if (document.all.expiryTime.value!="0:0")
                { document.all.expiryTime.value = newTime.getMinutes() + ":" + newTime.getSeconds(); }      
            setTimeout("Timer()", 1000);
        setTimeout("Timer()", 1000);

<input type=text name="expiryTime" size=5>

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question