Jump to content
  • Advertisement
Sign in to follow this  
yanuart

[web] How do we know how many ppl online

This topic is 5099 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there an easy php script to know how many ppl online on your site ? I found one tutorial but it uses database and all.. isn't there anything simpler :)??

Share this post


Link to post
Share on other sites
Advertisement
You going to need to have a database unless there is some php code that you can see how many sessions you site has open, but you need to have sessions in your site to do that too.

Share this post


Link to post
Share on other sites
What does "connected" even mean? If I hit your main page, am I "connected"? For how long?

The best way is probably to track the user using a cookie, and store a copy of that cookie in a database with a last-seen-time. Each time you get the same user back, you update the database entry last-seen-time for that cookie (and perhaps increment a visit counter). Seeing "active users" is then as easy as selecting the count of cookies that have a last-visit-time from 10 minutes or go or newer (for whatever value of "10 minutes" you prefer).

Share this post


Link to post
Share on other sites
Counting the number of active sessions is probably the cheapest way to do it. Another way would be to have a database that records the last time a session hit a page then use some maths to say <10mins == active. I'd personally go with the active sessions as you can change the session timeout to be lower if you need ot (at least you can in ASP).

Share this post


Link to post
Share on other sites
You wouldn't need to if your server has an application dictionary, like ASP.

It'd then be a case of setting up a function in the global.asa file (for ASP) to increment an Application("VisitCounter") variable on Session_OnStart and decrement it on Session_OnEnd. I'm sure PHP has this functionality too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!