How many users currently life connected

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
beso4ever
Forum Newbie
Posts: 10
Joined: Fri Jul 20, 2007 10:02 am

How many users currently life connected

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: How many users currently life connected

Post 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.
beso4ever
Forum Newbie
Posts: 10
Joined: Fri Jul 20, 2007 10:02 am

Re: How many users currently life connected

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: How many users currently life connected

Post by onion2k »

Use 10 minutes instead of 3 minutes then.

You'll never make a completely accurate counter. It's not possible.
User avatar
Kastor
Forum Newbie
Posts: 24
Joined: Thu May 01, 2008 2:29 am
Location: Grodno, Belarus
Contact:

Re: How many users currently life connected

Post by Kastor »

Also you can use JavaScript based on Ajax which will send request on your site and refresh the session
Post Reply