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

    if (isset($_COOKIE['remember_user'])) {
        unset($_COOKIE['remember_user']); 
        setcookie('remember_user', '', -1, '/'); 
        return true;
    } else {
        return false;
    }