fiddy Posted October 13, 2006 Share Posted October 13, 2006 Hi,I am looking for a way to track users who are logged in to my website. I thought of maintaining it in the DB and reset that DB entry when they logout. But, If the user go's out without logging out (by clicking the close button in the browser), it will show the status of the user as online always.Expecting help related to this....Thanks,Fiddy.[color=black][/color] Link to comment https://forums.phpfreaks.com/topic/23835-tracking-the-online-users-of-a-website/ Share on other sites More sharing options...
vbnullchar Posted October 13, 2006 Share Posted October 13, 2006 i use this on my site. place this on top of your page [code] function remInActiveUsers() { $timeout = time()-(10*60); $query = "update members set mem_online=false, mem_session_id='' WHERE u_timestamp < '$timeout'"; $this->query($query); }[/code] add user after logging onyour site[code] function addActiveUsers($id){ $time = time(); $ip = $_SERVER['REMOTE_ADDR']; $query = "INSERT INTO forum_active_users(u_userid, u_timestamp, u_ip) VALUES('$id','$time','$ip')"; $this->query($query); }[/code] Link to comment https://forums.phpfreaks.com/topic/23835-tracking-the-online-users-of-a-website/#findComment-108255 Share on other sites More sharing options...
fiddy Posted October 13, 2006 Author Share Posted October 13, 2006 Hi,Thanks for your help. Will this work if i close the window and login again instantly.ThanksFiddy Link to comment https://forums.phpfreaks.com/topic/23835-tracking-the-online-users-of-a-website/#findComment-108257 Share on other sites More sharing options...
fiddy Posted October 20, 2006 Author Share Posted October 20, 2006 Thanks friends .. Link to comment https://forums.phpfreaks.com/topic/23835-tracking-the-online-users-of-a-website/#findComment-111682 Share on other sites More sharing options...
Daniel0 Posted October 20, 2006 Share Posted October 20, 2006 vbnullchar: Why not just use this query: [code]DELETE FROM forum_active_users WHERE u_timestamp='{$timeout}';[/code] Then you wont end up with a lot of rows in that table. Link to comment https://forums.phpfreaks.com/topic/23835-tracking-the-online-users-of-a-website/#findComment-111693 Share on other sites More sharing options...
fiddy Posted October 20, 2006 Author Share Posted October 20, 2006 Ok. Thanks for your guidence. Link to comment https://forums.phpfreaks.com/topic/23835-tracking-the-online-users-of-a-website/#findComment-111698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.