Jump to content

[SOLVED] Tracking Online Status


adam84

Recommended Posts

When the user logs in, the members page get loaded, I then insert their ID and the time they logged in into a table.

 

The members page uses AJAX to load all the site's content, so the member's page doesn't ever get refreshed unless the user chooses to refresh the page.

 

If the user refreshes the page, I do a check to see if they are already in the table (already logged in). If they are in the table I skip the insert query else I do the insert query(initial load).

 

Then I added an AJAX function on the onUnload event in my <BODY> of the members page, that will remove the user from the 'online table'.

 

Is this the right way of doing this, or is there a better way?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/118822-solved-tracking-online-status/
Share on other sites

Not really how I'd do it, especially because they may not have Javascript on.  I'd update their "last_activity" column in the users table on every page, and then when displaying who's online, just search for who had activity in the last 5 minutes.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.