Web Development

Technical Training

How To Use Server Side Variables

Your I.P. Address Is: 38.107.179.230
Your Browser/Platform Is:
CCBot/1.0 (+http://www.commoncrawl.org/bot.html)

 

If you've ever wondered how to display your visitor's I.P. address, Browser Version or any number of other 'interesting' things on your web pages, here's how.

First, however, you must meet a few conditions.

  1. Your Web Server/Host must support "Server Side Includes" If you are not sure, ask your hosting provider.
  2. You must give the HTML file on which you want to display the Server variables the extension .shtml rather than just .html (.sht for three character extensions.) Don't Forget the "S"
  3. Once this is done, merely include the code from the left side of the table to produce the results on the right side. Yes, it looks like a Comment, and will not display locally, ONLY when you view the page on the server.
NOTE: Not all servers are set up to echo back all variables. Some hosts may choose not to provide some for security reasons and some server software may not support the full list. (This is not a complete list, merely the most common and useful.)

   This Code in This .shtml File Returns This From Our Server   
<!--#echo var="auth_type" -->  (none)
<!--#echo var="content_length" -->  (none)
<!--#echo var="content_type" -->  (none)
<!--#echo var="date_local" -->  Wednesday, 22-Feb-2012 22:52:56 CST
<!--#echo var="date_gmt" -->  Thursday, 23-Feb-2012 04:52:56 GMT
<!--#echo var="document_name" -->  server_vars.shtml
<!--#echo var="document_root" -->  /home/theeggle/public_html
<!--#echo var="document_uri" -->  /writing/server_vars.shtml
<!--#echo var="forwarded" -->  (none)
<!--#echo var="from" -->  (none)
<!--#echo var="gateway_interface" -->  CGI/1.1
<!--#echo var="http_cache_control" -->  no-cache
<!--#echo var="http_connection" -->  close
<!--#echo var="http_form" -->  (none)
<!--#echo var="http_host" -->  www.theegglestongroup.com
<!--#echo var="http_referrer" -->  (none)
<!--#echo var="http_ua_color" -->  (none)
<!--#echo var="http_ua_cpu" -->  (none)
<!--#echo var="http_ua_os" -->  (none)
<!--#echo var="http_ua_pixels" -->  (none)
<!--#echo var="http_user_agent" -->  CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
<!--#echo var="http_x_forwarded_for" -->  (none)
<!--#echo var="instance_id" -->  (none)
<!--#echo var="last_modified" -->  Friday, 22-Oct-2010 08:24:35 CDT
<!--#echo var="page_count" -->  (none)
<!--#echo var="path" -->  /usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/courier-imap/sbin:/usr/lib/courier-imap/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin
<!--#echo var="path_info" -->  (none)
<!--#echo var="path_translated" -->  (none)
<!--#echo var="query_string" -->  
<!--#echo var="query_string_unescaped" -->  (none)
<!--#echo var="remote_addr" -->  38.107.179.230
<!--#echo var="remote_host" -->  (none)
<!--#echo var="remote_ident" -->  (none)
<!--#echo var="remote_port" -->  45324
<!--#echo var="remote_user" -->  (none)
<!--#echo var="request_method" -->  GET
<!--#echo var="request_uri" -->  /writing/server_vars.shtml
<!--#echo var="script_filename" -->  /home/theeggle/public_html/writing/server_vars.shtml
<!--#echo var="script_name" -->  /writing/server_vars.shtml
<!--#echo var="script_uri" -->  (none)
<!--#echo var="script_url" -->  (none)
<!--#echo var="server_admin" -->  webmaster@theegglestongroup.com
<!--#echo var="server_addr" -->  69.65.3.173
<!--#echo var="server_name" -->  www.theegglestongroup.com
<!--#echo var="server_port" -->  80
<!--#echo var="server_protocol" -->  HTTP/1.1
<!--#echo var="server_signature" -->  
<!--#echo var="server_software" -->  Apache
<!--#echo var="total_hits" -->  (none)
<!--#echo var="tz" -->  (none)
<!--#echo var="unique_id" -->  T0XGKEVBA60ACni6TBYAAAAs
<!--#echo var="visp_domain" -->  (none)
<!--#echo var="visp_remote_addr" -->  (none)
<!--#echo var="visp_user" -->  (none)

Copyright ©2010 by T. S. Eggleston
Updated: October 22, 2010