Well, traditionally this would be done with sessions, and it's not exactly
the easiest topic for a newbie to get their head around.

It also never going to be a science -- how do you know when a user closes
their browser window or click onto another page?  You need to have clean-out
routines for "logged in" users who haven't had any activity for a while and
all sorts of other goodies.

Traditionally, most sites achieve things like "45 users and 12 guests
online" kinda thing using sessions, but I don't know if I've seen "45 users
looking this page right now" anywhere.

Hrm... a VERY NON SCIENTIFIC approach on a page-by-page basis would be to
log each hit on the page, and the time() that the hit was... boldly assume
that people will look at your page for 30 seconds or something, and keep a
counter of all hits within the last 30 seconds.  Like I said, not very geek
at all, not in any way scientific, but it's a quick fake.  Essentially, it's
more of a counter saying "48 hits in the last 30 seconds" than "48 people
looking at this page right now".

If you want to achieve this properly though, it's going to take you a few
hours to get your head around sessions, which can only be a good learning
experience any way.

Justin French

on 23/06/02 11:53 PM, Pag ([EMAIL PROTECTED]) wrote:

> Is it possible to code in PHP a small indicator on a site saying how many
> people are viewing that page at the moment?
> Sorry if its a silly question, but i am a newbie at PHP. If it is, could
> you point me in the good direction? i mean, some function or something.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to