View Full Version : How many people viewing Counter
05-07-2007, 02:26 PM
On my homepage I want a counter that tells me how many people are online right now. Not a normal counter that increments, but like one saying "1 person is online" or "0 people is online" or "204 people online".
It doesn't have to be one that increments/decrements without you refreshing the page, but it would be great! :cool:
05-07-2007, 03:28 PM
It all depends on what you have available to you? Do people login to your site? Do you want it to count people not logged into your site (if there is a login)? Do you have a database like MySQL? etc. We need to know more about your setup. Also, there are scripts online that do this depending, again, on your setup.
If no logins, you can do something as simple as creating an include file that would be at the top of every page on your site. It will take the person's IP and see if it can find it in the log file or DB. If it's in there, reset the "last activity" timestamp for that IP and if it's not in there, add it to the file/DB and record the current timestamp in "last activity". On top of that, it will go through every IP's "last activity" timestamp, and if it's "expired", meaning if it's been 10 minutes (or whatever time you want) since the "last activity" timestamp, then remove that IP. At the end, count up the total list of IPs and that's the number of people logged in to your page.
If you have logins, it'll be slightly more complex seeing that you don't want to count IPs coming from your members, but same kind of idea.
Hope that gets you started.
05-09-2007, 03:43 PM
Application("usersOnline") = Application("usersOnline") + 1
Application("usersOnline") = Application("usersOnline") - 1
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.