RE: [PHP] Count online users question
| From: | Vail, Warren | Date: | Wed, 26 Nov 2003 23:14:00 +0000 |
| Subject: | RE: [PHP] Count online users question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-171136@lists.php.net to get a copy of this message | ||
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