I am creating a static website (to be published on github pages) and want to use cookies to store website state for the user. But I get the following error while setting cookies:
Cookie “buttonState” will be soon rejected because it has the “sameSite” attribute set to “none” or an invalid value, without the “secure” attribute. To know more about the “sameSite“ attribute, read https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite
I have been using following js code to set cookies:
function set_cookies(jsonObj={},expires="",path="/"){
for(var key in jsonObj){
var temp = (key+"="+jsonObj[key]+";");
if(expires!=="")
temp += ("expires="+expires+";");
if(path!=="")
temp+= ("path="+path);
console.log(temp);
document.cookie = temp;
}
}
set_cookies({"buttonState":"compile");
How do I address this issue?