ColdFusion Tutorial
Displaying the users TCP/IP address and the browser
Example one we use cgi.
Example two we use getHttpRequestData function and looping through the headers structure.
Notice, both examples have been tested on a local host.
Code for example one:
<cfoutput>
<b>Your TCP/IP address is:</b>#cgi.remote_addr#<br>
<b>You are using:</b>#cgi.http_user_agent#<br>
</cfoutput>
The output from example one:
Your TCP/IP address is: 127.0.0.1
You are using: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Alexa Toolbar; Dreamweaver MX 6.1.1842)
Code for example two:
<cfset information = getHttpRequestData()>
<cfloop collection = "#information.headers#" item = "entry">
<cfoutput><b>#entry#:</b>#information.headers[entry]#<br></cfoutput>
</cfloop>
The output from example two:
ACCEPT-LANGUAGE: en-us
~~~~~~~~~~~~~~~: ~~~~~ ~~~~~~~
COOKIE: CFID=7306; CFTOKEN=12132415
CONNECTION: Keep-Alive
HOST: localhost
USER-AGENT: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Alexa Toolbar; Dreamweaver MX 6.1.1842)
ACCEPT: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*
ColdFusion Tutorial test
Displaying the users TCP/IP address and the browser
User information using CGI
Your IP address is:
38.103.63.62
You are using:
CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
No User Comments.
No User Comments, be the first one to write your comments?
