php, updating database when users appear inactive

Associate
Joined
11 Oct 2008
Posts
268
When a user logs in to my members area, their online status is set to 2 in my database and they are displayed as online for everyone else to see. And when they click log out their online status is set to 1 and they are no longer shown as online.

My problem is when the session expires due to inactivity, the database isnt updated and they are still shown as online. So whenever the access a page in the members area I have made it so that time also gets entered into the database. And my goal is to have the users online page auto refresh every 5 minutes to check the current time against the time stored in the database for that user and if 15 minutes has past, have the online status in the database updated to 1 again.

im using pdo but im a novice at it and havnt been able to find much help on google. Is there a way i can use an if statement to check the two times and only update the online field to 1 for the inactive users while leaving the users who appear active as 2?

Sorry if this was confusing, i wasnt too sure how to word it properly.
 
Back
Top Bottom