I'm currently on an external website and attempting to use JavaScript to remove a cookie.
Here's what I tried in the console:
function deleteAllCookies() {
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
var eqPos = cookie.indexOf("=");
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
}
}
deleteAllCookies()
This code is meant to make the document cookie expire in 1970.
However, when I then run:
document.cookie.split(";")
The cookies still appear to be intact. Any thoughts on why this might be happening?
PS: The code snippet above was sourced from a question on stackoverflow at Clearing all cookies with JavaScript