I wrote a while ago a function for removing cookies using mootools. Which worked great. I'm now trying to get it to work in jQuery using the js-cookie libary. I've been trying to get this to work for about 4 hours now and I've now started to bang my head on the table :(
function deleteAllCookies() {
console.log('got to delete all cookies');
var cookies = document.cookie.split(";");
console.log("cookie length"+cookies.length);
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;
Cookies.remove(name, null);
console.log("name is "+name);
}
}
so it finds two cookies and gets the names correctly but it only deletes one of them (the first one). If I run it again it deletes the second one. Any ideas what I'm doing wrong. (I call the function from a onmousedown event for testing)
thanks