next up previous contents
Next: Accessing Documents on the Up: CGI (Common Gateway Interface): Previous: Security Concerns   Contents

CGI Environmental Variables

In addition to information which is transmitted through CGI variables (like dest, month and day in the previous example), a large amount of information is transfered to CGI programs through environmental variables. These variables can be accessed in your program in the usual way, that is, by using the eviron dictionary of the os module. Table 8.6 lists the names and meanings of some of these environmental variables.


Table 8.6: Some Environmental Variables Passed through CGI
Name Contents
HTTP_COOKIE Persistent data stored in cookies
HTTP_REFERER URL of refering document
HTTP_USER_AGENT Type of browser being used
QUERY_STRING URL Fragment after ?
REMOTE_ADDR IP Address of user
REMOTE_HOST Hostname of user
REMOTE_USER Username, if authentication was used
SERVER_NAME Hostname of server
SERVER_PORT Port number of server
SERVER_SOFTWARE Name and version of server software



next up previous contents
Next: Accessing Documents on the Up: CGI (Common Gateway Interface): Previous: Security Concerns   Contents
Phil Spector 2003-11-12