删除一个 cookie [英] Remove a cookie

查看:29
本文介绍了删除一个 cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想删除 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;
}

这篇关于删除一个 cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆