Jump to content

Who's Online Stats


FishSword

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/246406-whos-online-stats/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/246406-whos-online-stats/#findComment-1265328
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.