The Visitors Log

[Previous] [Next]

The last technique I will discuss in this chapter is one that has been occurring without you even realizing it. Every time you run the Timesheet solution and view a page, the page logs this fact in the Visits table in the Timesheets.mdb database. If you have run the solution and saved or submitted a few timesheets, this table will already contain quite a bit of data. To view the data, click the Administration button on the navigation bar, and then click the View The Visitors Log button on the Site Administration page. The resulting page is much like the Hours Worked Analysis page just discussed, but this page shows the records of individual visits instead of the records of hours worked.

This type of logging can be an extremely useful debugging and monitoring tool, and it is actually not that invasive to the normal operation of the system. Most of the ASP pages in this solution have the following block of code near the top:

 ' Log the visit Dim sPage       ' Name of this page sPage = Request.ServerVariables("PATH_TRANSLATED") sPage = Mid(sPage, InStrRev(sPage,"\")+1) m_cn.Execute "INSERT INTO Visits Values ('" & sPage & "', '" & _     m_sCurUser & "', #" & Now & "#)" 

The code quickly determines the name of the current page by using the PATH_TRANSLATED server variable and looking for the last backslash (\) to extract only the page name. It then inserts a row into the database, passing the page name, the current user (obtained from the LOGON_USER server variable), and the current system time. You can encapsulate this into a method and make it even easier to use. You might also want to write more information into the log, such as the query string parameters passed to the page, the values of form fields, the cookie values (CERT_COOKIE), the server IP address on which the request arrived (LOCAL_ADDR), or even the entire set of HTTP headers (ALL_HTTP).



Programming Microsoft Office 2000 Web Components
Programming Microsoft Office 2000 Web Components (Microsoft Progamming Series)
ISBN: 073560794X
EAN: 2147483647
Year: 1999
Pages: 111
Authors: Dave Stearns

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net