Handling uncontrolled Logoff from Website

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
beath
Forum Newbie
Posts: 2
Joined: Sun Jun 27, 2004 6:10 am
Location: Zurich - Switzerland
Contact:

Handling uncontrolled Logoff from Website

Post by beath »

hiya

i'm having a problem with a counter that shows the numbers of logged-in users. the bookkeeping works fine, if the users logoff from the website by using the logoff-button. but if they just close the browser, they still remain as active. this is not exactly a language-based problem, more a conceptual problem.

any ideas?

thanks and hang loose
beat

ps: i'm aware of the fact, that in general this is a client-side problem, but perhaps there are any ideas how to deal it with a server-script...)
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Normal method during bookkeeping is to log when the user has performed something/reloaded. Then If current_time greater then last time done something time + (fixed time period) assume they are logged out.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Alternatively, if you're using the OO approach, and each user is an object, you can set up a destructor to log the user off (destroy the session, I guess)...
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

yea the best way to go is in the users table each time they reload the time update the time, and when someone else comes on the page get your script to see if the time of the last activitiy is longer than like 5min, and if so change their status to logged off
Post Reply