Session Tracking

Results 1 to 3 of 3

Thread: Session Tracking

  1. #1
    Join Date
    Dec 1969

    Default Session Tracking

    Is it possible to build a special page that the webmaster has access to that will show where everybody is on their site through the session or application object? I thought I saw something similar to this on one asp book site but I can not find it now.

  2. #2
    Chris Willey Guest

    Default RE: Session Tracking

    It would take a lot of work to do exactly what you&#039re saying. Essentially you would need to change the value of a session variable every time a user enters, and change it again when a user leaves. The best way to do that is through global.asa, which is called anytime a user enters a particular directory (created in IIS as a virtual directory, pointing to an actual directory). Within global.asa, you can set session and application variables. Session variables are what you would use here; specifically, set one that increases every time a user enters the directory, and decreases when one leaves. You can do that as follows:<BR><BR>&#060;script language="VBScript" runat="server"><BR>Sub Application_OnStart<BR>Session("UserCount") = 0<BR>End Sub<BR><BR>Sub Session_OnStart<BR>Session("UserCount") = Session("UserCount") + 1<BR>End Sub<BR><BR>Sub Session_OnEnd<BR>Session("UserCount") = Session("UserCount") - 1<BR>End Sub<BR><BR>Sub Application_OnEnd<BR>Session("UserCount") = ""<BR>Session("UserCount") = Nothing<BR>End Sub<BR>&#060;/script><BR><BR>Now you can create a page that shows you that status of UserCount whenever you want. That will tell you how many users are currently on your site (specifically within the directory that the global.asa file controls).<BR><BR>As for telling "where everybody is," you could possibly do that using another session variable (or several), but I don&#039t know how useful that would be. Your Web logs will tell you that, and you can look at them anytime you want (I suppose you could create an asp page to query the logs, but why do that when there are so many programs written for that purpose already?).

  3. #3
    Kelly Connell Guest

    Default RE: Session Tracking

    Thanks for the response Chris, I did something similar to that except I created a database table and updated everytime a user went to a new page and removed them when the session timed out. <BR><BR>The reasoning behind this is more for debugging and testing the website out more than anything, when I have a user on my intranet tell me the app crashed or they hit a bug it is much easier to check a single page that shows me the querystring, the session vars, etc... for that user and all of the other users currently on.<BR><BR>I will most likely remove this from any production code, because a database update every time every user hits a page could slow things down a tad more than I would like<BR><BR>If anybody would like I could email them the code and the table structure.

Posting Permissions

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