how to unset cookie in PHP?

前端 未结 6 453
旧时难觅i
旧时难觅i 2020-12-02 01:31

I need to figure out how to unset this cookie. Everything I tried so far has failed.

This is how I am currently unsetting it and it doesn\'t seem to work.

         


        
6条回答
  •  自闭症患者
    2020-12-02 02:18

    There are few security concerns regarding you code, however to answer your question, to unset a cookie in php, all you need to do is to set expiration time to a time in the past:

    setcookie("user_id", "", time()-10, "/");
    

    "loginform.php" is not a valid domain, that might be the problem here.

提交回复
热议问题