Detect moment when user closed session

Discussion in 'ASP .Net' started by NWx, Feb 2, 2004.

  1. NWx

    NWx Guest

    Hi,

    I have the following question:

    I have an app that uses user login/logout to identify users
    When user logon, I register logon time in a session variable
    When user logoff using the logout link, I also register logoff time and
    update accordingly the logging history table.
    However user can simply close the browser without logoff, so his session was
    closed.
    Is there any way to detect when this is happening, to allow me to get the
    time and update logoff time field appropriate?

    Thank you.
     
    NWx, Feb 2, 2004
    #1
    1. Advertising

  2. I don't believe what you are trying to do can be done accurately, with a
    100% success rate (since it would require some client coding). If a client
    wants to close their browser and not let the server know about it, they most
    certainly can do that. You could try some crude javascript code to pop up a
    window when the browser is closing which would execute some logoff code, but
    with all the nice popup blockers these days...good luck.

    Here's another option, and I'll leave it to you to implement if you want to.
    For each page the user requests after the he is logged in, remember the
    time, that time is the logout time, unless you get another request. You
    could add a minute or so to it if you want to give the impression that the
    user stayed there and looked at the page for a minute. Now look at the
    session_end method in the global.asax file. Somehow set your logging
    history table with this value when this method fires.

    HTH,
    --Michael

    "NWx" <> wrote in message
    news:%...
    > Hi,
    >
    > I have the following question:
    >
    > I have an app that uses user login/logout to identify users
    > When user logon, I register logon time in a session variable
    > When user logoff using the logout link, I also register logoff time and
    > update accordingly the logging history table.
    > However user can simply close the browser without logoff, so his session

    was
    > closed.
    > Is there any way to detect when this is happening, to allow me to get the
    > time and update logoff time field appropriate?
    >
    > Thank you.
    >
    >
     
    Michael Ramey, Feb 2, 2004
    #2
    1. Advertising

  3. NWx

    NWx Guest

    Thank you for your answers.
    I thought about popup window, but you are right with the popup blockers.

    I'll try your second suggestion.

    Regards



    "Michael Ramey" <raterus@localhost> wrote in message
    news:...
    > I don't believe what you are trying to do can be done accurately, with a
    > 100% success rate (since it would require some client coding). If a

    client
    > wants to close their browser and not let the server know about it, they

    most
    > certainly can do that. You could try some crude javascript code to pop up

    a
    > window when the browser is closing which would execute some logoff code,

    but
    > with all the nice popup blockers these days...good luck.
    >
    > Here's another option, and I'll leave it to you to implement if you want

    to.
    > For each page the user requests after the he is logged in, remember the
    > time, that time is the logout time, unless you get another request. You
    > could add a minute or so to it if you want to give the impression that the
    > user stayed there and looked at the page for a minute. Now look at the
    > session_end method in the global.asax file. Somehow set your logging
    > history table with this value when this method fires.
    >
    > HTH,
    > --Michael
    >
    > "NWx" <> wrote in message
    > news:%...
    > > Hi,
    > >
    > > I have the following question:
    > >
    > > I have an app that uses user login/logout to identify users
    > > When user logon, I register logon time in a session variable
    > > When user logoff using the logout link, I also register logoff time and
    > > update accordingly the logging history table.
    > > However user can simply close the browser without logoff, so his session

    > was
    > > closed.
    > > Is there any way to detect when this is happening, to allow me to get

    the
    > > time and update logoff time field appropriate?
    > >
    > > Thank you.
    > >
    > >

    >
    >
     
    NWx, Feb 3, 2004
    #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. hb
    Replies:
    6
    Views:
    748
  2. Chris

    Detect if browser closed

    Chris, Apr 27, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    10,831
    Chris
    Apr 27, 2005
  3. news.microsoft.com
    Replies:
    2
    Views:
    492
    news.microsoft.com
    Dec 17, 2005
  4. Glen
    Replies:
    3
    Views:
    2,420
  5. Matt Kruse
    Replies:
    5
    Views:
    312
    Richard Cornford
    Sep 9, 2003
Loading...

Share This Page