NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP "connection_aborted" and Capturing User Log Out / Browser Close

Mitch Pirtle mitch.pirtle at gmail.com
Tue Jan 11 20:27:17 EST 2005


On Tue, 11 Jan 2005 14:06:00 -0500, Peter Sawczynec <psaw at pswebcode.com> wrote:
> 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.

Hey Peter,

What I have done in the past was include a timestamp in the session
(cookie that is, as well as in an 'online' table in the database), and
after 5 minutes the authentication script updates the timestamp in the
database.  I then have a cron job running every 5 minutes that deletes
any records with timestamps > 5 minutes old.

In essence, if you close the browser or leave without logging out,
your 'session' will get tossed in 5 minutes.

I'd love to hear of other approaches, to see what makes the most sense.

-- Mitch



More information about the talk mailing list