Session timeout

Posted on 2006-04-11
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
    LVL 6

    Assisted Solution

    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.
    LVL 9

    Assisted Solution

    > 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)
    LVL 9

    Expert Comment

    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

    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>

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Suggested Solutions

    Title # Comments Views Activity
    ajax, jquery and web method in 46 50
    Effect on button 11 40
    Put text in a picture ASP.NET C# 2 26
    send mail from 8 9
    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now