Sometimes you might want to find out more information on your visitors. We can do this using the server variables. These are environment variables that tell us about the environment that your application is running in. Server variables can tell us everything from what browser the visitor is using, to the visitor's ip address, or the last page the visitor came from.
For example I can tell that you are using the Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) browser, and the IP (Internet Protocol) address of your internet connection is 222.165.168.210
Server Variables can be called with the following syntax;
<% Request.ServerVariables("Variable Name") %>
Below are a list of some of the more common server variables and how you use them:
This tells us the page the visitor came from
<% = Request.ServerVariables("HTTP_REFERER") %>
The last page you came from:
This is a simple way to display a go back link on a page
get a visitors IP address
<% =Request.ServerVariables("REMOTE_ADDR")%>
Your IP address is: 222.165.168.210
Find host name of client
<%=Request.ServerVariables("REMOTE_HOST")%>
The result: 222.165.168.210
This will return the hostname or IP address of the server :
find the server domain name
<% =Request.ServerVariables("SERVER_NAME")%>
Server domain name is:
www.codefixer.com
This returns the software running on the server
<% Request.ServerVariables("SERVER_SOFTWARE")%>
The Server software is: Microsoft-IIS/6.0
Display the virtual path to the script or application being executed
<% =Request.ServerVariables("SCRIPT_NAME") %>
The result: /tutorials/servervariables.asp
Find out what browsers / Operating System a user has
Display users browser and opertaing system
<% = Request.ServerVariables("HTTP_USER_AGENT") %>
Your browser is: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
To get a list of all the ServerVariables you can simply copy paste and run this script.