用户登录
用户注册

分享至

删除一个 cookie

  • 作者: 直插主题
  • 来源: 51数据库
  • 2022-12-08

问题描述

当我想删除 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;
}
软件
前端设计
程序设计
Java相关