Sanjeev
Sanjeev

Reputation: 1866

Unable to parse __utmz cookie

We use GA for tracking and part of the tracking involves storing the __utmz cookie value in our DB. I have a problem in understanding why is CF 10 not able to parse the __utmz cookie.

CF10 is not parsing or properly retrieving the value of __utmz cookie Or just about any cookie value that has an 'equal (=)' sign in it other than the CFGLOBALS.

Here is the screen shot of the issue (using CFDUMP of COOKIE scope) -

What it should look like -

Proper Google Analytic cookie read

What it is looking like -

Improper Google Analytic cookie read

Server Config: CF10, IIS 7.5, Win 2k8

Upvotes: 5

Views: 455

Answers (2)

David Hammond
David Hammond

Reputation: 3306

I just ran into this problem. Some code that was working in CF8 stopped working in CF10. I created this function to get the raw cookie value:

<cffunction name="GetRawCookie" output="false" returntype="string">
    <cfargument name="cookieName" type="string" required="true">
    <cfset local.cookies = GetHttpRequestData().headers.cookie>
    <cfset local.cookieValue = "">
    <cfset local.match = reFindNoCase("(?:^|;)\s*" & arguments.cookieName & "=([^;]+)", local.cookies, 1, true)>
    <cfif local.match.pos[1] gt 0>
        <cfset local.cookieValue = mid(local.cookies, local.match.pos[2], local.match.len[2])>
    </cfif>
    <cfreturn local.cookieValue>
</cffunction>

Upvotes: 0

Sanjeev
Sanjeev

Reputation: 1866

Ok! I found the way to mitigate this problem. By using the GetHttpRequestData() method.

<cfscript>    
    _cookie = GetHttpRequestData().headers.cookie;
</cfscript>

This will return an ; delimited list of cookie values. I used regEx to pick the __utmz value I needed.

Upvotes: 1

Related Questions