Programming with HTML Forms / Logging
Programming with HTML Forms
This section describes how to transparently log information about users.
In fact, such data may already be available in an access log file, which records all browser accesses to the server, and is set up through the httpd configuration file. However, for many applications such general purpose logging may not capture all the information required. For instance, a common reason for recording accesses is to have the application offer different facilities to different users. Thus, in a video ordering service, it might be useful to record the types of films that a user likes, so that similar films can be pointed out to him when he next makes an order. For such specific information, it is better to have the application carry out the necessary logging.
In qdir, access details are collected from four environment variables: REMOTE_USER, REMOTE_IDENT, REMOTE_HOST, and REMOTE_ADDR. In addition, the local time on the server is recorded.
The extra code is wrapped up inside the record_details() function which is called early in qdir.
One drawback with the first three environment variables is that there is no guarantee that they will have values. REMOTE_USER is only bound if the client and server support user authentication, and REMOTE_IDENT relies on support for RFC 931 identification. REMOTE_HOST may not be bound, but the IP address equivalent will be assigned to REMOTE_ADDR.
Another important point to remember is to make the file which stores the log data writeable by everyone. This is necessary since Web servers run CGI programs as if they belonged to nobody.
Comments are welcome
Copyright 1996 Andrew Davison and
Created: Apr. 26, 1996
Revised: May 7, 1996