Remove a cookie

后端 未结 22 1547
没有蜡笔的小新
没有蜡笔的小新 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:28

    If you want to delete the cookie completely from all your current domain then the following code will definitely help you.

    unset($_COOKIE['hello']);
    setcookie("hello", "", time() - 300,"/");
    

    This code will delete the cookie variable completely from all your domain i.e; " / " - it denotes that cookie variable's value all set for all domain not just for current domain or path. time() - 300 denotes that it sets to a previous time so it will expire.

    Thats how it's perfectly deleted.

提交回复
热议问题