Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Jul 2, 1998

Notify Session Time Out When Using ASP

Each time a user connects to an ASP Web site, they are assigned a SessionID. Each session times out after 20 minutes by default (although you can adjust the timeout duration). This frees server resources when a browser doesn't return to a site within the specified time. The problem is that there's no way to send a message to the client browser either just before or anytime after the session times out. The user doesn't know that the session has timed out. You can alleviate the problem by putting this script in each page which lets users know that their session has timed out. You can easily modify it to notify a user before the script times out:
 
<script language="javascript">
    var elapsedTime = 0;
    // set to the Session.Timeout value to notify users
    // one minute after their Session times out.
    var maxTime = (<%=Session.Timeout%> + 1) * 60;
    var oneSecond;
    oneSecond = window.setTimeout("timeoutCheck();",1000);
    function timeoutCheck() {
        elapsedTime = elapsedTime + 1;
        if (elapsedTime > maxTime) {
            window.location = "youTimedOut.htm";
        }
        else {
          oneSecond = window.setTimeout("timeoutCheck();",1000);
        }
    }
</script>
Russell Jones,
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date