Sign in to follow this  

[web] How do we know how many ppl online

This topic is 4815 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

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

This topic is 4815 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this