PC.net
HomeHome : Help Center : Question
ShareShare

What are environment variables used by Web servers?

Answer: Environment variables store hidden values on a Web server. They change dynamically, such as when a new page is loaded or a form is posted. The variables can provide useful information, such as the user's IP address or Web browser type. This data is typically stored in a "hash" named $ENV and can be accessed using a Web script written in a language such as PHP or ASP.

Below are some common environment variables:

  1. remote_addr - the visitor's IP address
  2. http_user_agent - the type of Web browser the visitor is using
  3. remote_port - the port the visitor is using to connect to the server
  4. redirect_status - a redirect code for moved pages, such as 301 or 302
  5. request_method - may be "GET" or "POST," two ways of processing online forms
This data is sometimes used by dynamic websites to provide customized information to users. For example, the remote_addr variable provides the user's IP address, which can often be used to determine a user's general location. A weather website might use this information to automatically provide users with weather forecasts specific to the areas where they live.

Similarly, the http_user_agent variable is commonly used by Web developers to determine what Web browser a visitor is using. This can be useful since different browsers sometimes interpret HTML and CSS in different ways. By identifying what browser each visitor is using, developers can provide custom information to different Web browsers using a single Web page.

Published: August 10, 2009 — by Per Christensson

Answer from the PC Help Center
https://pc.net/helpcenter/web_server_environment_variables
space