For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > October 2006 > when browser is closed









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author when browser is closed
toffee

2006-10-12, 6:59 pm

Hi,

I have a site accessible via a login system. I would like to track login and
logout time for every user. I can get the login time no problem - as every
time someone logs in, a row is added to a mysql table. The problem happens
with logout as almost no one uses the logout button; rather they just close
the browser window.
My question is therefore - am i able to capture the time the browser is
closed? all login data is stored in a session; so is there a way to find out
the time the session got deleted which would mean user has left ?

Kind regards

T


Gordon Burditt

2006-10-12, 6:59 pm

>I have a site accessible via a login system. I would like to track login and
>logout time for every user. I can get the login time no problem - as every
>time someone logs in, a row is added to a mysql table. The problem happens
>with logout as almost no one uses the logout button; rather they just close
>the browser window.
>My question is therefore - am i able to capture the time the browser is
>closed?


No.

>all login data is stored in a session; so is there a way to find out
>the time the session got deleted which would mean user has left ?


The session being deleted does NOT mean the user has left. And the
user may leave WITHOUT closing the browser window (he may type in
a URL, click on a bookmark, etc.) Unless the user is highly motivated
to explicitly log out (like the site contains private info or can
be used to spend real money), the vast majority of logouts are going
to be by timeout.

You also don't get to run code when the session data is about to
be deleted.

PleegWat

2006-10-12, 6:59 pm

In article <egjuer$s8$1@news.freedom2surf.net>, toffee says...
> I have a site accessible via a login system. I would like to track login and
> logout time for every user. I can get the login time no problem - as every
> time someone logs in, a row is added to a mysql table. The problem happens
> with logout as almost no one uses the logout button; rather they just close
> the browser window.
> My question is therefore - am i able to capture the time the browser is
> closed? all login data is stored in a session; so is there a way to find out
> the time the session got deleted which would mean user has left ?


I'd suggest saving the last page call in your table. Each time a page is
called during one session, update the last page call column to the
current time.
--
PleegWat
Remove caps to reply
Dundonald

2006-10-12, 6:59 pm


Gordon Burditt wrote:

>
> No.


Not strictly true. The onunload event can be captured within a page and
by use of a HTTP redirect used to call appropriate code to clean up
session data etc ... Be warned though as always various browsers don't
support onunload, but my experience with IE has so far been OK since
version 4.

>
>
> The session being deleted does NOT mean the user has left. And the
> user may leave WITHOUT closing the browser window (he may type in
> a URL, click on a bookmark, etc.) Unless the user is highly motivated
> to explicitly log out (like the site contains private info or can
> be used to spend real money), the vast majority of logouts are going
> to be by timeout.


The onunload also triggers when a user moves off of your page by typing
a different URL.

>
> You also don't get to run code when the session data is about to
> be deleted.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com