Session_OnEnd

Discussion in 'ASP .Net' started by BillGatesFan, Feb 22, 2005.

  1. BillGatesFan

    BillGatesFan Guest

    Is there a way to warn the user that there Session is about to end? I'm
    using Forms authentication and when there session ends it takes them
    back to the login screen like it is designed to do.


    Also it there anyway to make it take the user to a different page once
    the session ends?


    Thanks
    BillGatesFan, Feb 22, 2005
    #1
    1. Advertising

  2. Hi BillGatesFan,

    > Is there a way to warn the user that there Session is about to end?


    Yes. You would have to know the Session Timeout, and add a JavaScript to
    each page that uses the JavaScript setTimeout() function to execute a
    JavaScript function shortly before the timeout.

    > Also it there anyway to make it take the user to a different page once
    > the session ends?


    The user may be out playing basketball by the time the Session ends. (IOW,
    no)

    Let me explain: Session timeout occurs when NO REQUESTS have been made for a
    period of (usually) 20 minutes. Without a Request, how can there be a
    response?

    However, using the technique I described above, you could do a client-side
    redirect just prior to the Session timeout. Of course, keep in mind that the
    new Request will reset the timeout, and the Session will not end, unless you
    call Session.Abandon on the target page.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "BillGatesFan" <> wrote in message
    news:...
    > Is there a way to warn the user that there Session is about to end? I'm
    > using Forms authentication and when there session ends it takes them
    > back to the login screen like it is designed to do.
    >
    >
    > Also it there anyway to make it take the user to a different page once
    > the session ends?
    >
    >
    > Thanks
    >
    Kevin Spencer, Feb 22, 2005
    #2
    1. Advertising

  3. Hi BillGatesFan,

    Have a client side script using window.setInterval() method to fire a yes/no
    window to fire near the session end time..

    SetInterval: Evaluates an expression each time a specified number of
    milliseconds has elapsed..
    Check this link for more information..
    http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/setinterval.asp

    Once the session times out either you can refresh the page and check on the
    post back and redirect him to login page or alert him...

    Hope this helps..

    Need any help, do post a msg back

    Happy Coding

    "BillGatesFan" wrote:

    > Is there a way to warn the user that there Session is about to end? I'm
    > using Forms authentication and when there session ends it takes them
    > back to the login screen like it is designed to do.
    >
    >
    > Also it there anyway to make it take the user to a different page once
    > the session ends?
    >
    >
    > Thanks
    >
    >
    =?Utf-8?B?VmlzaG51LUNoaXZ1a3VsYQ==?=, Feb 22, 2005
    #3
  4. BillGatesFan

    Michael Guest

    Add this to every page_load that you want the redirect on timeout to happen

    Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60) +
    10) & ";URL=timeout.aspx")

    This will redirect to a page after a specified interval in seconds.

    You could also use this method to redirect to a warning page by changing the
    '+10' to a '-30', checking that the result is > 0, and the url to your
    warning page. In page load of your warning page, set the refresh to redirect
    to your login page or some sort of message page when the timeout actually
    occurs.

    HTH..


    "BillGatesFan" <> wrote in message
    news:...
    > Is there a way to warn the user that there Session is about to end? I'm
    > using Forms authentication and when there session ends it takes them
    > back to the login screen like it is designed to do.
    >
    >
    > Also it there anyway to make it take the user to a different page once
    > the session ends?
    >
    >
    > Thanks
    >
    Michael, Feb 22, 2005
    #4
    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. anand

    my session_onend is not working

    anand, Jul 9, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    1,379
  2. Hans Kesting

    Session variables and Session_OnEnd

    Hans Kesting, Aug 18, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    600
    Hans Kesting
    Aug 19, 2003
  3. steve
    Replies:
    0
    Views:
    415
    steve
    Aug 25, 2003
  4. rob

    session_onend event not firing

    rob, Aug 27, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    2,333
    Anand
    Aug 28, 2003
  5. Manfred Braun
    Replies:
    3
    Views:
    761
    Manfred Braun
    Aug 30, 2003
Loading...

Share This Page