Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool How many people viewing Counter

    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!

  • #2
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    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.

    -Shane

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    global.asa :

    Code:
    <%
    sub Session_OnStart
      Application("usersOnline") = Application("usersOnline") + 1
    end sub
    
    sub Session_OnEnd
      Application("usersOnline") = Application("usersOnline") - 1
    end sub
    %>

    ?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •