Remove a cookie

sanders picture sanders · Mar 26, 2009 · Viewed 585k times · Source

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?

Answer

Nikunj K. picture Nikunj K. · Nov 14, 2013

You May Try this

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