I\'m trying to set session cookie in javascript like this:
document.cookie = \'name=alex; path=/\'
But Chrome doesn\'t delete it even if I
Google chrome has a problem if you set and unset cookie improper way. This is php code. Thought this will give you idea.
Set cookie
setcookie('userLoggedIn', 1, 0, PATH);
Wrong way and will not work (notice PATH is missing)
setcookie('userLoggedIn', 0, time()-3600);
Correct way fixes issue on google chrome
setcookie('userLoggedIn', 0, time()-3600, PATH);
A simple alternative is to use the new sessionStorage object. Per the comments, if you have 'continue where I left off' checked, sessionStorage will persist between restarts.
This maybe because Chrome is still running in background after you close the browser. Try to disable this feature by doing following:
However, I think Chrome should check and delete previous session cookies at it starting instead of closing.
I had the same problem with "document.cookie" in Windows 8.1, the only way that Chrome deletes the cookie was shutting it from task manager (not a really fancy way), so I decided to manage the cookies from the backend or use something like "js-cookie".
The solution would be to use sessionStorage
, FYI: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
This can be caused by having Chrome set to Continue where you left off.