global.asa - current user counting
Posted: 3/28/2003 11:31:51 AM
By: Comfortably Anonymous
Times Read: 2,493
0 Dislikes: 0
Topic: Programming: Web Applications
How Many People Are on your Site Right Now?
By Joðo Vieira

--------------------------------------------------------------------------------

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. www.yourpage.com/global.asa). 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
We'll,... 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)
Discussion View:
Replies:

global.asa - current user counting
Posted: 3/28/2003 11:31:51 AM
By: Comfortably Anonymous
Times Read: 2,493
0 Dislikes: 0
Topic: Programming: Web Applications
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. www.yourpage.com/global.asa). 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)