How to Expire Cookies? [duplicate]

0

Hey guys,   This is the following I created a login system that uses a cookie to remember the user's password so everything works fine, the problem is when it comes to inspiring these cookies, in the panel of my website there is a button that is nothing more than a small form that when clicked sends via post a request to the same page of which it has a condition saying if the method post exits exist then expires the cookie user and password, then this is the problem cookies do not expire in any way already tried all possible methods that I found on the internet like these.

setcookie("usuario"," ",time()-10);
setcookie("usuario","",time()-10);
setcookie("usuario",NULL);
setcookie("usuario");

None of these methods worked, would anyone know if they needed anything else?

    
asked by anonymous 02.05.2018 / 16:24

1 answer

0

I think this will solve the problem:

if (isset($_COOKIE['usuario'])) {
    unset($_COOKIE['usuario']);
    setcookie('usuario', null, -1, '/');
    return true;
} else {
    return false;
}
    
02.05.2018 / 16:45