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 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Current # of Viewers viewing this site...

    I am trying to create a script where I can see the current # of visitors viewing my website. I am using a Global.asa file and here is what I have come up with:


    Global.asa

    Code:
    Sub Application_OnStart
     Application("Active")=0
    End Sub
    
    Sub Application_OnEnd
     'no code is needed here
    End Sub
    
    
    Sub Session_OnStart
     Session.Timeout=20
     Session("Start")=Now
     Application.Lock
     Application("Active")=Application("Active")+1
     'this adds 1 to the number of active users
     'when a new user hits
     Application.unlock
    End Sub
    
    Sub Session_OnEnd
     Application.Lock
     Application("Active")=Application("Active")-1
     'this subtracts 1 from the number of active users
     'when a new user leaves
     Application.unlock
    End Sub


    Viewers.asp

    Code:
    <%
    Response.Write("There are " & Application("Active"))
    Response.Write(" users on this page!")
    %>

    The problem is that I never get a number of current viewers when viewing the viewers.asp page. The viewers are tracked by sessions, so I test by opening FireFox and IE and going to the viewers page, but nothing. Any comments or suggestions would greatly be appreciated. Thanks.

    ~Isaac~
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com

  • #2
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I feel pretty stupid cause I found my answer a few monutes after I posted, but I searched and worked on the script for like 2 hours before posting. Anyways information about how to do this kind of script can be found here for anyone else who might want to do this: http://www.asp101.com/resources/active_users.asp


    ~Isaac~
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com


  •  

    Posting Permissions

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