Page 1 of 1
How many users currently life connected
Posted: Wed May 14, 2008 6:34 am
by beso4ever
hi all
please i need idea or code to implement this target
i need to know
How many users currently life connected to my site?
Thanks all
Re: How many users currently life connected
Posted: Wed May 14, 2008 6:46 am
by onion2k
Every time someone connects to the site, or clicks a link on the site, update a database table to record the time of the click and their user id (or session id). To get the number of users you just need to query the number of unique ids that have been updated in the last few minutes.
Re: How many users currently life connected
Posted: Wed May 14, 2008 6:58 am
by beso4ever
thanks onion2k for your replay

i understand from your answer that i will use specified time ex: 3 minutes
but if the user will signed in for 10 minutes then his record not changed
so our counter will be wrong
Re: How many users currently life connected
Posted: Wed May 14, 2008 8:24 am
by onion2k
Use 10 minutes instead of 3 minutes then.
You'll never make a completely accurate counter. It's not possible.
Re: How many users currently life connected
Posted: Wed May 14, 2008 8:59 am
by Kastor
Also you can use JavaScript based on Ajax which will send request on your site and refresh the session