I'm using the following functions to create and delete cookies. This has worked great in the past, but recently I started debugging via localhost and I have noticed the deleteCookie
function is no longer working.
function setCookie(cname, cvalue, exsecs) {
let expires = "";
if (exsecs) {
var d = new Date();
d.setTime(d.getTime() + (exsecs * 1000));
expires = "expires="+ d.toUTCString();
} else {
expires = "expires=Fri, 31 Dec 9999 23:59:59 GMT"
}
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function deleteCookie( name ) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
As you can see, it's pretty straight forward. Is there a better way to "delete" cookies that works locally? Or is there some configuration change I can make?