Testing for client screen resolution script issue.
Hello;
I am working on a small script that checks for the users resolution. I know the only way to do this is by a java script sending the info to coldfusion then adding it to a db. So I wrote this script and it grabs the users resolution, but once a size is put into the db, all the other users that hit the site, are using the same resolution. I find that hard to believe.
This is my code:
These tags are set in my application.cfc file in onsessionstart
<!--- This grabs the users resolution --->
<CFSET ScreenWidth = "<script>document.write(screen.width);</script>">
<CFSET ScreenHeight = "<script>document.write(screen.height);</script>">
<!--- then add it to the DB --->
<cfquery name="tracking" datasource="#APPLICATION.dataSource#" dbtype="ODBC">
INSERT INTO tracking ( REMOTE_ADDR, HTTP_USER_AGENT, SWidth, SHight, TRACK_DATE, PATH_INFO )
VALUES(
<cfqueryparam value="#Trim(CGI.REMOTE_ADDR)#" cfsqltype="CF_SQL_VARCHAR">,
<cfif Len(Trim(HTTP_USER_AGENT)) GT 1>
<cfqueryparam value="#Trim(CGI.HTTP_USER_AGENT)#" cfsqltype="CF_SQL_VARCHAR">,
</cfif>
<cfqueryparam value="#Trim(ScreenWidth)#" cfsqltype="CF_SQL_VARCHAR">,
<cfqueryparam value="#Trim(ScreenHeight)#" cfsqltype="CF_SQL_VARCHAR">,
<cfqueryparam value="#Now()#" cfsqltype="CF_SQL_TIMESTAMP">,
<cfqueryparam value="#Trim(PATH_INFO)#" cfsqltype="CF_SQL_LONGVARCHAR">
)
</cfquery>
then to read it I use this:
<cfquery NAME="tracking" datasource="#APPLICATION.dataSource#">
SELECT ID, REMOTE_ADDR, HTTP_USER_AGENT, SWidth, SHight, TRACK_DATE, PATH_INFO
FROM tracking
ORDER BY ID
</cfquery>
<cfoutput query="tracking">
#SWidth# x #SHight#
</cfoutput>
That is it. Anyone have any idea what I did wrong on this? Even a better more simple way would be good.
thank you.
CFmonger