How to check member is online or not?

hoangthienphuc's Avatar, Join Date: Mar 2007
Go4Expert Member
I am trying to build a statictis utility in my CMS website. This utility will list of user_member (register) in the systems is online or not and it get IP address of that member pc and display information about their visited history ( They has visited other pages before enter my pages ).
I tried to solve this problem for a long time but it's still not effective. How to do that? Please help me. Thanks for any response.
jwshepherd's Avatar, Join Date: Aug 2007
Team Leader
using session variables is the easiest way for the first part but adding the extra information may require another database table
TABLE tbl_online
user | active | ip | referer

In the login.php page add a line to insert a record containing the userid, a 1,the ip, http_referer
in the logoff page update the table active from 1 to a 0 (inactive)

use select * from tbl_online where active <>0;
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
People may not log off but close the browser and so a cron job should update the database for non existing sessions.