user912830823
user912830823

Reputation: 1352

JS: How to remove .domain.com cookie from www.domain.com

On the website that has a redirection from domain.com to www.domain.com there is a cookie __utmz that is set with this plugin: https://github.com/clancychilds/ReturnOfTheUTMZ/blob/master/compiled/latest/utmz.min.js

Apparently, this cookie is set on .domain.com not on www.domain.com. Here are cookie details:

Name:   __utmz
Content:    0.1234567890.1.1.utmcsr=blablabla.co.uk|utmccn=(referral)|utmcmd=referral|utmctr=/blablabla
Domain: .domain.com
Path:   /
Send for:   Any kind of connection
Accessible to script:   Yes
Created:    Tuesday, January 24, 2017 at 3:34:02 PM
Expires:    Sunday, July 23, 2017 at 4:34:02 PM

Now im trying to remove this cookie from all browsers visiting the website, but nothing of the following worked so far for my browser:

document.cookie = '__utmz=;domain=.style.com.;expires=Thu, 01 Jan 1970 00:00:00 UTC';

document.cookie = '__utmz=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/';

What would be the best way to remove this cookie using JS (no access to jquery or any other library)?

Upvotes: 0

Views: 5488

Answers (1)

Kabelo2ka
Kabelo2ka

Reputation: 417

This is late, but for other guys, You can just use:

document.cookie = "cookieName=; Path=/; domain=domain.com; expires=Thu, 01 Jan 1970 00:00:01 GMT;";

A . will be prepended to the cookie domain automatically.

Hope that helps

Upvotes: 1

Related Questions