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 CCBot/1.0 (+http://www.commoncrawl.org/bot.html) browser, and the IP (Internet Protocol) address of your internet connection is 38.107.191.108
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
Find host name of client
<%=Request.ServerVariables("REMOTE_HOST")%>
The result: 38.107.191.108
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/7.5
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:
CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
To get a list of all the ServerVariables you can simply copy paste and run this script.
Get the best asp web hosting provider now and save 30%
Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.