Page 2 of 2

Re: PLEASE HELP - Update database on browser close??

Posted: Sat Nov 13, 2010 5:07 am
by ewannnn
Sorry I shuold be more specific, it does not update the database, it just does nothing.
What i want is for the following query to be executed if the user closes the browser:
mysql_query("UPDATE users SET status='Offline' where alias='".($_SESSION['alias'])."';");
The user status is online even if the browser is closed and reopened, it does not execute the query. What i want is to update the database on browser close.

Re: PLEASE HELP - Update database on browser close??

Posted: Sat Nov 13, 2010 10:36 am
by s.dot
A better way (and very common way) to determine users online is to use the time they were last active. Update a timestamp when a user performs an action.

If a user hasn't performed an action with the last X (say 5) minutes, then they are considered to be offline.

That is how this board does it.