Browser is closed.

I

IveCal

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

Bart Van der Donck

IveCal said:
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,
 
B

Bart Van der Donck

web.dev said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top