Advanced Users Online

Many people have tutorials out there that allow you to count the number of active users online with the use of the global ASA file; however, they do not show you the user's location and "what they are doing".

i.e, going to your users_online.asp page may show the following:

  • user J.Buttafucco is viewing the guestbook (/dev/guestbook.asp)
  • user A.Fischer is deleting a guestbook entry (/dev/guestbook_delete.asp)
  • user T.Harding is beating people up (/dev/beat_peeps_up.asp)

The Pages Code

Now, on EVERY PAGE, you should add this code:

<% @LANGUAGE = VBSCRIPT %>
<%
Session("location") = Request.ServerVariables("SCRIPT_NAME")
Session("doing") = "viewing the guestbook"
Call UpdateActiveUser
%>

On the page right after a user logs in, replace the above code with: (this will check to see if the Session exists, and if not, add it to the database)

<%
Session("location") = Request.ServerVariables("SCRIPT_NAME")
Session("doing") = "viewing the page right after a login"
Call LogActiveUser
Call UpdateActiveUser
%>

 

The Logout Page

Note how we're calling 2 procedures. Finally, on the page you use to log a user out, replace the first instance of the code above with :

<%
Session("location") = Request.ServerVariables("SCRIPT_NAME")
Session("doing") = "logging out"
Call UpdateActiveUser
Call LogOutActiveUser
%>

This calls 2 procedures as well and updates the user to be LOGGING OUT and then removes them from the database (all done when the session EXPIRES, not when the user uses our LOGOUT system) Also note that you can use:

<%= Application("usersOnline")%> to show # of active sessions open

and

<%= Application("visits")%> to show the total times the server's been visited.

 

Comments

Great

July 23, 2002 by scre wdanger

Great tutorial. Just one thing would have make things lot easier for the newbies. I can imagine that volks will have some problems in implementing the script so why not provide them the files and the database. Then things will be lot more easier to understand.

Anyways thanxalot finally i got it workin,  was lookin for this for a long time.

RE: Great

October 19, 2002 by arend rutgers

Great??

I don't even know why its rated 4.7?? It doesnot work. There are many errors. I am working on it if somebody sorted out then please let me know.

 

You must me logged in to write a comment.