I know this i a duplicate from Clearing all cookies with JavaScript
but i still got a problem. I didn't add a path or a domain to my cookie but if i want to delete them by pressing the logout button the cookie seems untouched
Here i built the cookie and x is the response from a AJAX-Request witch gives me the informations i need:
function setCookie(x) {
document.cookie = x;
}
but if i want to delete them in the same javascript-script it seems untouched and i don't get any errors This is the onLoad-function witch gets called when the user logout
function onLoad() {
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";
alert(document.cookie);
}
}
can anyone tell my why it dosent work. should i add a domain or a path even when i dont add one when i creates the cookie?