View Light

RE: global.asa - current user counting

Parent Message
Oops, the code is being hidden from view due to the tags within it. Trying again with a PRE tag, hopefully it will show now...  (If not, view the source to get the code)

I think this one is really easy, and even if you never used global.asa don't worry, just put the one I have at this page for download at the root of your page (e.g. If you are unfamiliar with global.asa, be sure to also check out this article on Global.asa. Now all you need is to keep track of a counter as each new user enters your page. You'll also need to decrement your counter when someone leaves, and have code to display the current count.

Explaining Application Variables

      Application variables work like session variables except that the value of Application variables are the same for all the users, and the values of session variables are different for each user. An instance of every session variable is created for every user. Only one instance of all Application variables is created when the server starts up. Hopefully with the example you will understand better.

File: Global.asa

File: main.asp
Well,... after lots of research I made this code that show the users that are seeing your page on real-time by getting the info from the application variable...

   response.write "Are Now " & Application("WhosOn") & " users at this page."

Happy Programming!

Rating: (You must be logged in to vote)
Comfortably Anonymous
12/7/2004 10:13:39 AM
0 Dislikes: 0