phpcookies

How to remove a cookie in PHP?


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 can I really remove the cookie?


Solution

  • You May Try this

    unset($_COOKIE['remember_user']); 
    setcookie('remember_user', '', 1, '/'); 
    

    However, path (and domain) parameter must be exactly same as was used when setting the cookie.