Browser is closed.

Discussion in 'Javascript' started by IveCal, Jul 20, 2006.

  1. IveCal

    IveCal Guest

    Hello... I want to record all logins and logouts. The problem occurs
    when a user CLOSES the browser without clicking the Logout link. How
    will I record the "logout time" using javascript? (I'm using PHP to on
    the server side.) PLEASE reply...
     
    IveCal, Jul 20, 2006
    #1
    1. Advertisements

  2. IveCal wrote:

    > Hello... I want to record all logins and logouts. The problem occurs
    > when a user CLOSES the browser without clicking the Logout link.


    Or he might surf away to another page.

    > How will I record the "logout time" using javascript? (I'm using PHP
    > to on the server side.) PLEASE reply...


    I think your best option is a timer on page-level, so that a session
    automatically expires if a given time interval of inactivity is
    exceeded.

    If your application is running in a popup-window, and the only
    reasonable action besides clicking a logout-button is closing the
    popup, then you could use something like this:

    <body onUnload="alert('leaving page...');">

    Hope this helps,

    --
    Bart
     
    Bart Van der Donck, Jul 20, 2006
    #2
    1. Advertisements

  3. IveCal

    web.dev Guest

    Bart Van der Donck wrote:
    > <body onUnload="alert('leaving page...');">


    However, this event also occurs if the user also refreshes the page.
     
    web.dev, Jul 20, 2006
    #3
  4. web.dev wrote:

    > Bart Van der Donck wrote:
    > > <body onUnload="alert('leaving page...');">

    >
    > However, this event also occurs if the user also refreshes the page.


    Yes, ... and if user presses Backspace, right-click > previous, resend
    form, right-click > next, click previous-button, click next-button,
    etc. That's why I said "reasonable action"; I think one should only use
    it if the app runs in a popup window with right-click disabled, perhaps
    disable keys F5, Backspace, CTRL-KEYs, etc.

    --
    Bart
     
    Bart Van der Donck, Jul 20, 2006
    #4
    1. Advertisements

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:
    954
  2. Marina

    Re: capture 'browser closed'

    Marina, Jun 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,625
    M. Zeeshan Mustafa
    Jun 24, 2004
  3. Nikhil Patel

    saving data when browser is closed

    Nikhil Patel, Aug 26, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    629
    Weston Weems
    Aug 26, 2004
  4. =?Utf-8?B?c3Vu?=

    end session when the browser window is closed.

    =?Utf-8?B?c3Vu?=, Apr 6, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    10,066
    James Steele
    Apr 6, 2005
  5. Chris

    Detect if browser closed

    Chris, Apr 27, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    11,128
    Chris
    Apr 27, 2005
  6. =?Utf-8?B?R2FyeQ==?=
    Replies:
    1
    Views:
    627
    =?Utf-8?B?R2FyeQ==?=
    Nov 11, 2005
  7. Christian Blackburn
    Replies:
    8
    Views:
    619
    Christian Blackburn
    Jun 21, 2006
  8. Matt Kruse
    Replies:
    5
    Views:
    555
    Richard Cornford
    Sep 9, 2003
Loading...