Cookie Won't Delete

后端 未结 4 1869
误落风尘
误落风尘 2021-01-22 08:03

So I have this code on my index.php:


If t

相关标签:
4条回答
  • 2021-01-22 08:34

    Not the cleanest but Check the time zone is correct Ensure you are nuking the correct cookie( case sensitive ) Failing all of they over writing the cookie will nuke it anyway So...

    Setcookie('mycookie') // nukes the cookie with a blank entry

    0 讨论(0)
  • 2021-01-22 08:41

    You may want to check if the path the cookie is set at is correct. By default PHP sets the cookie path to the directory it's set in and it will not be available (nor possible to delete) from different locations.

    Few more tips:

    • there is no need to unset $_COOKIE and $_SESSION
    • instead of redirecting using a meta tag redirect with HTTP headers:

      header('Location: /index.php'); // or whatever is the path you want to redirect to
      
    0 讨论(0)
  • 2021-01-22 08:43

    remove this line

    unset($_COOKIE['RememberMe']);

    0 讨论(0)
  • 2021-01-22 08:45

    Cookie cancelations can sometimes require the same time value as they were set.

    setcookie("RememberMe", "", time()-1209600);
    
    0 讨论(0)
提交回复
热议问题