Jump to content

Online Members


Ads

Recommended Posts

1) Make a datetime field in your users table called something along the lines of "last_active"

 

2) On your header page (so it is called on every click) put an update query that will put the current date/time in the last_active field (this can be done using NOW()).

 

3) Your query to pull the users who have been active within the last 5 minutes will look something like this:

SELECT username FROM users WHERE last_active > (NOW() - INTERVAL 5 MINUTE)

Link to comment
https://forums.phpfreaks.com/topic/83304-online-members/#findComment-423845
Share on other sites

heres a function that someone previously created that works fine

 

http://www.phpfreaks.com/forums/index.php/topic,171853.0.html

 

This code will count every user that is online, including "guests". I'm assuming from the OP using the word "member" they are wanting logged in users only.

Link to comment
https://forums.phpfreaks.com/topic/83304-online-members/#findComment-423852
Share on other sites

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.