How to delete/unset a cookie on php?

后端 未结 6 1500
轻奢々
轻奢々 2021-01-17 11:38

I want to unset/delete my existing cookie with this:

setcookie (\"user\", \"\", time()-1); 
unset($user);

But cookies can not be deleted or

6条回答
  •  星月不相逢
    2021-01-17 12:14

    When deleting a cookie you should assure that the expiration date is in the past.

    Delete example:

    // set the expiration date to one hour ago
    setcookie("user", "", time()-3600);
    

提交回复
热议问题