Page 1 of 1

users online

Posted: Sun Jan 02, 2005 1:21 am
by shiznatix
what would be the best way of doing a users online were it tells how many people are currently viewing the website? i dont want to do it with counting session id's so is there another way?

Posted: Sun Jan 02, 2005 2:13 am
by John Cartwright

Code: Select all

1. Each page view
          a. check if session id is present in database
                       i) if exists
                             a. update row with current time
                      ii) if does not exist
                             a. create a new row with current time and session id
          b. check if any rows have expired time (compare current time with time in database)
                       i) if exists
                             a. delete the row
          c. SELECT COUNT (`id`) FROM `usersonline`
Something along these lines..

Posted: Sun Jan 02, 2005 9:18 am
by d3ad1ysp0rk
Phenom:
shiznatix wrote: i dont want to do it with counting session id's so is there another way?
;)

Posted: Sun Jan 02, 2005 9:46 am
by timvw
the OP could count in has access.log how many times the page has been requested the last 5 minutes and then say that all those requests where someone visiting that page...

but sessions are a mechanism that allow to work-around the fact that http is stateless.. i don't see any good reason not to use it....

Posted: Mon Jan 03, 2005 12:12 am
by shiznatix
ya but when u use sessions they could goto the website, then without closing the browser goto another website and the session would still exist...rite?

Posted: Mon Jan 03, 2005 3:26 am
by feyd
eventually, the session gets destroyed. You shouldn't have to worry about that.

Posted: Mon Jan 03, 2005 4:11 pm
by shiznatix
so there is no way to have a 100% acurate count of the amount of ppl viewing my website at any givin time?

Posted: Mon Jan 03, 2005 4:25 pm
by timvw
as i've said before...... check your access.log for that.

Posted: Mon Jan 03, 2005 4:44 pm
by John Cartwright
LiLpunkSkateR wrote:Phenom:
shiznatix wrote: i dont want to do it with counting session id's so is there another way?
;)
we all have these moments...

Posted: Mon Jan 03, 2005 4:49 pm
by feyd
even with checking the access log, you only get a snapshot of how many requests have been done. Not how many are actually looking at the page. If you want to know definitively you need to require a "real-time" connection. This means Java, or a custom built application. At any rate, there is always a margin of error.

Posted: Mon Jan 03, 2005 10:18 pm
by shiznatix
poopy o well thanks for the help