CGI Environment Variables

Variable: Output for your session on this system
A brief description of the variable.
Auth_Type:
The authentication method used to validate a user.
Content_Length:
The length of the data (in byes or the number of characters) passed to the CGI program through standard input.
Content_Type:
The MIME type of the query data, such as "text/html".
Date_local:
Current date and time in the local time zone.
Date_GMT:
Current date and time in GMT.
Document_Name:
The current file.
Document_Root:
The directory from which Web documents are served.
Document_URI:
Virtual path to the file.
Gateway_Interface:
The revision of the Common Gateway Interface that the server uses.
HTTP_Accept:
A list of the MIME types that the client can accept.
HTTP_From:
The email address of the user making the request. Most browsers do not support this variable.
HTTP_Referer:
The URL of the document that the client points to before accessing the CGI program.
HTTP_User_Agent:
The browser the client is using to issue the request.
Last_Modified:
Last modification date and time for current file.
Path_Info:
Extra path information passed to a CGI program.
Path_Translated:
The translated version of the path given by the variable PATH_INFO.
Query_String:
The query information passed to the program. It is appended to the URL with a "?".
Query_String_Unescaped:
Undecoded query string with all shell metacharacters escaped with "\".
Request_Method:
The method with which the information request was issued.
Remote_Addr:
The remote IP address of the user making the reqest.
Remote_Host:
The remote hostname of the user making the request.
Remote_Ident:
The user making the request. This variable will only be set if NCSA IdentityCheck flag is enabled, and the client machine supports the RFC 931 identification scheme (identd).
Remote_User:
The authenticated name of the user.
Script_Name:
The virtual path (e.g., /cgi-bin/program.pl) of the script being executed.
Server_Name:
The server's hostname or IP address.
Server_Port:
The port number of the host on which the server is running.
Server_Protocol:
The name and revision of the information protocol the request came in with.
Server_Software:
The name and version of the server software that is answering the client request.


HTML Syntax:
<!--#echo var="VARIABLE_NAME"-->
Example:
Suppose we want to attempt to print out the email address of the current user. The code would look something like:
Your email address is <!--#echo var="REMOTE_IDENT"-->@<!--#echo var="REMOTE_HOST"-->.

That line will print out:
Your email address is @.


Most of the information in this table came from CGI Programming on the World Wide Web by Shishir Gundavaram.