删除一个 cookie

2021-12-21 00:00:00 cookies php

当我想删除 Cookie 时,我会尝试

When I want to remove a Cookie I try

unset($_COOKIE['hello']);

我在 Firefox 的 cookie 浏览器中看到 cookie 仍然存在.我怎样才能真正删除 cookie?

I see in my cookie browser from firefox that the cookie still exists. How can I really remove the cookie?

推荐答案

你可以试试这个

if (isset($_COOKIE['remember_user'])) {
    unset($_COOKIE['remember_user']); 
    setcookie('remember_user', null, -1, '/'); 
    return true;
} else {
    return false;
}

相关文章