Re: figure out how many users are online?
| From: | Richard Lynch | Date: | Sat, 16 Dec 2000 22:52:05 +0000 |
| Subject: | Re: figure out how many users are online? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30690@lists.php.net to get a copy of this message | ||
> is there a simple way to figure out how many users are logged onto my
site?
> i dont care when they logged on, or for how long, i simply want to know
how
> many ppl are on. i have mysql database running if that helps.
Unfortunately, you have to care when they logged on, and for how long, in
order for the question to make any sense:
Each HTTP request is a completely separate and independent exchange, with no
real concept of "logged on" from page to page.
You *could* set up something that marked a person as "logged on" at the top
of each script, and "logged off" at the end of the script... This is the
most accurate representation of "logged on" from an HTTP specifcation
perspective.
This, however, is probably not the most useful implementation from a
real-world perspective... :-^
You will need to require users to log in, or use session IDs
(http://php.net/session_start) to track them.
You will need to maintain a user table, with each page hit marking that user
as "still active" with a timestamp.
Then, users who have not been active within a certain time limit you choose
are denoted as "logged off", while the others, obviously, are "logged in".
PHPLib has a great deal of this work already done for you, but it can take a
fair amount of time to figure out PHPLib and there's some overhead of
features you may not need...