Chrome doesn't delete session cookies

后端 未结 13 1692
有刺的猬
有刺的猬 2020-11-22 05:25

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

13条回答
  •  后悔当初
    2020-11-22 06:01

    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);
    

提交回复
热议问题