3
I have a website http://www.meusite.com which creates several cookies with different domains such as: http://tracker.meusite.com and http://w3.meusite.com.
How can I do in Javascript to delete the cookies of the realm meusite?
3
I have a website http://www.meusite.com which creates several cookies with different domains such as: http://tracker.meusite.com and http://w3.meusite.com.
How can I do in Javascript to delete the cookies of the realm meusite?
1
This code forces the expiration of all cookies whose scope is the current website:
function apagaCookies() {
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";
}
}
Source: Original post in the OS in English.
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
@Jorgeb. For security restrictions you can only manipulate cookies that belong to the website you are on.
– OnoSendai
Okay, thank you :)
– Jorge B.