I use the following codes to log users out from a web app. while logging in I set cookie email and password, but after logging out, visiting the home page automatically logs the user in again, probably because the cookie wasn't successfully destroyed. Please how do I get it right. Here is log out code
function log_out() {
$old_user = $_SESSION['valid_user'];
unset($_SESSION['valid_user']);
unset($_SESSION['login']);
unset($_SESSION['blog_addr']);
$result_dest = session_destroy();
setcookie('email', '');
setcookie('pswd', '');
if (!empty($old_user))
if ($result_dest)
return true;
else
$msg = 'Could not log you out ';
else
$msg = 'You have not been logged in so you are not logged out ';
return $msg;
}///:~