Highlighted

Cookie duplicated values from subdomain and domain

Silver Contributor
Silver Contributor
Hello, What happens if I have a cookie called "CookieExample" defined at "www.domain.com" and defined at ".domain.com" When I debug with WebCompanion, I have two populated values cp.CookieExample two times with different values. How can I check if I have a cookie at www.domain.com, create a cookie at .domain.com and delete the cookie at www.domain.com? Extra info: We are migrating from another TMS solution and previously our cookies were stored at www.domain.com, but now are stored at .domain.com
1 REPLY 1
Highlighted

Cookie duplicated values from subdomain and domain

Employee Emeritus
Lluis, As far as I know, the meta data for cookies (domain, path, etc) is not available to JavaScript, or really not available at all. However, I think we can assume that the cookie will be set on the "www.domain.com" domain. You could set this up with a couple extensions. 1) Create Data Source with the name of the current cookie "CookieExample" Select First Party Cookie as the Type. 2) Create Data Source with name like "cookie_example_value." Select UDO Variable as the Type. 3) Create Data Source with a new cookie name "NewCookieExample" and select First Party Cookie as the Type. 2) Add a Set Data Values Extension and configure it like: Set: cookie_example_value (js) To: Variable -> Select "Cookie Example (cp)" from the drop down 3) Add a Persist Data Values Extension and Configure it like the attached screenshot. 4) Add a JavaScript Code Extension and add the following: // Delete "CookieExample" Cooke Value utag.loader.SC('CookieExample','','da'); The extensions outlined need to be in the order they are described here. It is a good idea to add (Step 1, Step 2, Step3) to the titles of the the extensions and also use labels so others will know these extensions belong together. This will read the "CookieExample" cookie if it exists and create a new cookie called "new_cookie_value" cookie. The "new_cookie_value" cookie will equal the "CookieExample" cookie but be defined on the top level domain. Then the JS Code extension will delete the "CookieExample" cookie. Hope this helps.