Remove a cookie

后端 未结 22 1551
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 16:16

When I want to remove a Cookie I try

unset($_COOKIE[\'hello\']);

I see in my cookie browser from firefox that the cookie still exists. How

22条回答
  •  不要未来只要你来
    2020-11-22 16:45

    You can simply use this customize function:

    function unset_cookie($cookie_name) {
        if (isset($_COOKIE[$cookie_name])) {
            unset($_COOKIE[$cookie_name]);
            setcookie($cookie_name, null, -1);
        } else { return false; }
    }
    

    If you want to remove $_COOKIE['user_account'].
    Just use:

    unset_cookie('user_account');
    

提交回复
热议问题