Reputation: 39
how to add path=/ correctly? I added a setcookie with success. But i do not get the path correctly. If a user changes the settings (set the cookie) at a subfolder (www.domain.com/subfolder.html), it will generate a second cookie with the path /subfolder.
<script>
function standardmode(){
days=30; // number of days to keep the cookie
myDate = new Date();
myDate.setTime(myDate.getTime()+(days*24*60*60*1000));
document.cookie = 'standardmode=1; expires=' + myDate.toGMTString();
}
</script>
script from "mintedjo" Nov '08 https://www.webdeveloper.com/d/196412-creating-a-cookie-onclick-with-javascript/5
Upvotes: 0
Views: 51
Reputation: 39
document.cookie = 'standardmode=1; path=/; expires=' + myDate.toGMTString();
Upvotes: 1