FishSword Posted September 4, 2011 Share Posted September 4, 2011 Hiya, What's the best way of finding out and displaying the total number of users currently online, along a breakdown of how many of these users are members or guests? I also wish to find out and display the total number of users who were online today, along with a breakdown of how many of these users are members or guests. I've noticed that users of the same computer could of course use a different browser preference to another user of the same computer. What should happen in this situation? Any help is much appreciated. Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/246406-whos-online-stats/ Share on other sites More sharing options...
flappy_warbucks Posted September 4, 2011 Share Posted September 4, 2011 What's the best way of finding out and displaying the total number of users currently online In the database, put a column in the user table that holds the time of their last action. Put some code in with the session class that checks to see if they're logged in, and get that to update the time in the database everytime they do something (i.e. click a link) for example: session_start(); if (isset($_SESSION['user'])) { $query = "update users set tolc=\"". time(). "\" where user=\"". $_SESSION['user']. "\";"; // run that query. } You can then write another piece of code that, when you're pulling users from the database, you can get it to ignore users which have been idle for about 10/15 minutes. I've noticed that users of the same computer could of course use a different browser preference to another user of the same computer. What should happen in this situation? Nothing. If a user is using a different browser over the same session instance, then i'd start hashing the browser string in with an MD5'd session key. But as it's two separate users, then just leave it. Quote Link to comment https://forums.phpfreaks.com/topic/246406-whos-online-stats/#findComment-1265328 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.