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. Advertising

  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. Advertising

  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. 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. mike
    Replies:
    0
    Views:
    695
  2. hb
    Replies:
    6
    Views:
    760
  3. Marina

    Re: capture 'browser closed'

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

    saving data when browser is closed

    Nikhil Patel, Aug 26, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    581
    Weston Weems
    Aug 26, 2004
  5. Matt Kruse
    Replies:
    5
    Views:
    328
    Richard Cornford
    Sep 9, 2003
Loading...

Share This Page