[nycphp-talk] PHP

Peter Sawczynec psaw at
Tue Jan 11 14:33:09 EST 2005

This is a possible "almost does it" option. 

The time of every new page hit by the user can be entered as the newest
logout time. So if they never formally logout we at least have an
approximate Log Out time. If they really Log Out, we get the Log Out time
for real.

By the by, there is a way to rig something with JavaScript and the onUnload
event. But it has pitfalls too.

I am surprised now that PHP doesn't offer "on session start" and "on session
end" event capturing, or am I wrong?



-----Original Message-----
From: talk-bounces at [mailto:talk-bounces at] On
Behalf Of Rahmin Pavlovic
Sent: Tuesday, January 11, 2005 2:17 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] PHP

On Tue, 11 Jan 2005 14:06 , Peter Sawczynec <psaw at> sent:

>Using PHP, is there a simple way to capture browser shutdown or a 
>session termination event, so that a user's departure time from a site 
>can be captured when they don't use the formal Log Out button.
>I need to track user time logged into a site. I am using PHP sessions. 
>Currently, capturing the user Log In efforts and capturing the user Log 
>Out time when they hit Logout button.
>Any solution suggestions for capturing log out time of users who just 
>close the browser?

A possible solution would be log 'on-site' time by saving a timestamp of
every page view.  We do that in-part to prevent additional log-in's from the
same account during a given active timeframe.

New York PHP Talk
Supporting AMP Technology (Apache/MySQL/PHP)

More information about the talk mailing list