Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture browser settings, OS, etc 2

Status
Not open for further replies.

takethapowerback

IS-IT--Management
May 2, 2001
13
US
I need to write a script that captures browser settings, OS, etc. automatically as soon as a user visits our site. I also need the script to post each users info to a database. Has anyone done this before or maybe someone can steer me in the right direction with this. Thanks in advance for any help you can give me.

132.jpg

TTPB
 
here's some code to display CGI variables --

<CFOUTPUT>
<h3>cgi parameters</h3>
<table border=&quot;1&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot;>
<CFLOOP COLLECTION=&quot;#cgi#&quot; ITEM=&quot;foo&quot;>
<tr><td>cgi.#foo#&nbsp;</td><td>#cgi[foo]#&nbsp;</td></tr>
</CFLOOP>
</table>
</CFOUTPUT>

saving CGI variables into a database would be extra work (and incidentally, slow your site down -- is there a reason you can't get things like browser from your site logs?)

rudy
 
Sure.

What you want to do is use the cgi.HTTP_USER_AGENT variable. This will return the user agent string. This is the primary method of the browser to identify itself to the web server.

The string will look something like:
Code:
Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.0)

The trick is parsing it into something useful.
Take a look at the latest browsercap file ( It should get you started down the road of what you want to search for to identify particular browsers.

Something like:
Code:
<cfset searchpoint = FindNoCase(&quot; MSIE &quot;,cgi.HTTP_USER_AGENT)>
<cfif searchpoint gt 0>
	<cfset mybrowser = &quot;ie&quot;>
</cfif>

You can get as in depth and complex as you would like... or keep it simple (it would just mean some older browsers are mis-identified... which isn't necessarily the end of the world).

Or, of course, you could buy BrowserHawk and let cyScape do all the hard work (why reinvent the wheel).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top