0

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)?

MD. Khairul Basar
  • 4,976
  • 14
  • 41
  • 59
user912830823
  • 1,179
  • 3
  • 14
  • 25
  • Must see http://stackoverflow.com/questions/1062963/how-do-browser-cookie-domains-work – Vinay Feb 01 '17 at 16:34
  • not sure how to remove dot but the solution that worked for me is before setting value of cookies call a function to erase desired cookie from all paths, then set your cookie value. this will delete the old cookie and will create new cookie – Ekta Puri Dec 21 '20 at 01:36

1 Answers1

1

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

Kabelo2ka
  • 419
  • 4
  • 14