You can use only $_COOKIE
.
You can set the values in one $_COOKIE
thus:
setcookie("loginCredentials", $user, time() * 7200); // expira depois de 2 hours
To depress you can just leave the cookie value blank like this:
setcookie("loginCredentials", "");
And finally to check if the user is logged in:
if(isset($_COOKIE['user']['id'] && !empty(isset($_COOKIE['user']['id']))){
// Usuário logado.
}else{
// Usuário não esta logado.
}
This variable $user
could be something like this:
$user = array(
'id' => $id,
'name' => $name,
'login' => $login,
)
Just be careful not to leave passwords and information unprotected.
I recommend reading http://answall.com/questions/33664/remin-usu%C3%A1rio-com-seguran%C3%A7a/33684#33684
– marcusagm