Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2003
    Location
    Denver, CO
    Posts
    34

    Unanswered: Warn the user if thier session is about to end.

    Anyone know an easy way to pop a warning if a user's ASP session is about to end? Thanks!
    -Wigz

    ------------------------------------------------
    docendo discimus.

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    The session expires after a certain amount of inactivity. So you could either write some JavaScript to redirect the page to a logout page, or a META refresh that does the same. You could even use a combination of both. Use JS to pop up a message 5 minutes before the timeout, then use the META refresh to redirect to the logout page.
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    Feb 2003
    Location
    Denver, CO
    Posts
    34
    So I just have a JavaScript function count to like 19 mins 30 seconds (30 seconds before the default ASP session ends) and then pop a window asking if the user needs more time?

    There is no native ASP method to determine if a session is about to end or has ended?
    -Wigz

    ------------------------------------------------
    docendo discimus.

  4. #4
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Right.. make sure you make the popup window a browser popup.. I don't think the browser will redirect if you use a javascript alert() message box and it is still active when the page needs to be redirected.
    That which does not kill me postpones the inevitable.

  5. #5
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Oh.. if they click "Ok" from the popup window, you'll need to refresh the original page to restart the counter (or use the JS to restart it).
    That which does not kill me postpones the inevitable.

  6. #6
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    Quote Originally Posted by Seppuku
    Right.. make sure you make the popup window a browser popup..
    Was going to say - if the popup was a page from your server it would extend the session - as the server would not know that it was the javascipt requesting the page or the user.

    Quote Originally Posted by Seppuku
    I don't think the browser will redirect if you use a javascript alert() message box and it is still active when the page needs to be redirected.
    Don't think so either.

  7. #7
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Quote Originally Posted by rhs98
    Was going to say - if the popup was a page from your server it would extend the session - as the server would not know that it was the javascipt requesting the page or the user.
    Very true... you'd have to have some JS on that popup that counted down and redirected the parent page to the logout page (which kills the session) if the time elapses, then closed itself.
    That which does not kill me postpones the inevitable.

  8. #8
    Join Date
    Oct 2003
    Posts
    706
    Given the "memory-less" nature of the HTML protocol, the way I'd probably try to approach the problem is by sending the user a javascript which sets a timer and then reacts to it. So the user's computer is the one that actually generates the warning that the session is about to expire.

    It would be difficult, I think, to have the server computer generate the warning.
    ChimneySweep(R): fast, automatic
    table repair at a click of the
    mouse! http://www.sundialservices.com

  9. #9
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    I believe that's what we're saying.. a JavaScript timer on the client side would popup another browser window with a warning when time elapsed. That popup window would have another timer that would redirect the parent to a page that kills the session and closes itself if that second timer elapses.
    That which does not kill me postpones the inevitable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •