How to check automatically for "end of session" and force a page redirection?

Discussion in 'Javascript' started by Athenian, Jul 13, 2006.

  1. Athenian

    Athenian Guest

    Hi guys.

    Currently I need a javascript (client side) or vbscript(server side)
    code to check automatically for session expiration and force the
    redirection to a message page or the log-in page. All web site is built
    around asp pages.

    Thank you very much for your help
     
    Athenian, Jul 13, 2006
    #1
    1. Advertising

  2. Athenian

    RobG Guest

    Athenian wrote:
    > Hi guys.
    >
    > Currently I need a javascript (client side) or vbscript(server side)
    > code to check automatically for session expiration and force the
    > redirection to a message page or the log-in page. All web site is built
    > around asp pages.


    Use either setTimeout or setInterval to send an intermittent
    XMLHttpRequest from the client to check with the server to see if the
    session is still active at say 1 minute intervals. If the session has
    timed-out, redirect.

    It may be unreliable.


    --
    Rob
     
    RobG, Jul 14, 2006
    #2
    1. Advertising

  3. Athenian

    Jeremy Guest

    Re: How to check automatically for "end of session" and force a pageredirection?

    Athenian wrote:
    > Hi guys.
    >
    > Currently I need a javascript (client side) or vbscript(server side)
    > code to check automatically for session expiration and force the
    > redirection to a message page or the log-in page. All web site is built
    > around asp pages.
    >
    > Thank you very much for your help
    >


    Please clarify: do you want them to be taken to a log-in page
    immediately when their session expires, or the next time they request a
    page and their session has expired?

    If it's the former (which is a bad idea - what if they are working on
    something when their session expires? They are whisked away to a login
    page whether they like it or not? Some action on their end - i.e.
    requesting a page - should happen before you do this) then RobG's
    suggestion is what you're looking for.

    If it's the latter, you should ask in an ASP group. But it will go
    something like this (note, this is C# code as I don't use VBScript):

    if(Session["key_to_check"] == null)
    Response.Redirect("/myloginpage.asp");

    If you have authorization code already, I would be surprised if this
    code isn't already included. If the user's session is no longer valid,
    and they are still able to access protected pages, your site is a
    desperately insecure.

    Jeremy
     
    Jeremy, Jul 14, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jake

    Force Validation check

    Jake, Aug 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    457
  2. Replies:
    1
    Views:
    442
    Beauregard T. Shagnasty
    Oct 4, 2006
  3. Bob
    Replies:
    4
    Views:
    668
  4. Thomas Fujita
    Replies:
    1
    Views:
    307
    Kenny
    Oct 22, 2003
  5. Bubu
    Replies:
    0
    Views:
    103
Loading...

Share This Page