users online
Moderator: General Moderators
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
users online
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?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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`-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
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....
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....
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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.