This is a discussion on RE: [PHP] Count online users question within the PHP General forums, part of the PHP Programming Forums category; If your website uses PHP sessions, and you store those sessions in a database table you could; $query = "select ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
If your website uses PHP sessions, and you store those sessions in a
database table you could; $query = "select count(*) from session_table where " ."session_datetime > \"" .date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")." -1 hour")) ."\" "; ....the reset of a mysql query to get result. Note that the 1 hour is an arbitrary amount of time and people do come back after 1 hour, but if your session lifetime is set to be less than an hour, you may want to use that same time limit. You were correct in your original assumption that the count will almost never be very precise. Warren -----Original Message----- From: Mike D [mailto:mike@awn.com] Sent: Wednesday, November 26, 2003 2:57 PM To: php-general@lists.php.net Subject: [php] Count online users question Hi all, I am trying to figure an accurate way to calculate how many users are viewing a site, at any particular time. This task is very simple except for one part - How do you determine when a person has left the site...apache hasn't served anymore requests from a particular ip for xx minutes ?? - MD ................................... Mike Dunlop AWN, Inc. // www.awn.com [ e ] webmaster@awn.com [ p ] 323.606.4237 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |