How to extend a Session

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jalicej
    New Member
    • Jul 2007
    • 6

    How to extend a Session

    I have C#.net web application which is using sessions.
    When a session is going to end is it possible to show a message that the session is going to end and that do you want to continue. If the continue button is clicked the session should continue else the session can expire.
    How can i do it.
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    #2
    Originally posted by jalicej
    I have C#.net web application which is using sessions.
    When a session is going to end is it possible to show a message that the session is going to end and that do you want to continue. If the continue button is clicked the session should continue else the session can expire.
    How can i do it.
    Hmm, tricky one. Okay...as the page is being built check the Session.Timeout to find out how long the session lasts if no interaction is made.

    Build a javascript that runs a timer for a period shorter than the session timeout and starts when the page loads... when the timer elapses, fire a confirm box. If the OK button is clicked then use window.location = http://blahblah.com to reload the page and therefore resetting the session timer back to 0.

    It really is a hack to do what you want - in an ideal world when the session is about to timeout at the server end, it would notify the client - but that's not really achievable in the disconnected world of the web.

    Comment

    Working...