I’m trying to implement a simple PHP logout script. I have the below code. When logged in and I click on a link that redirects to the logout script, it doesn’t seem to realize I’m logged out and still displays the same information. However, once I close the tab, and re-open it, it no longer shows me the same information. Any ideas?
session_start();
session_destroy();
unset($_COOKIE['cookie_name']);
setcookie("cookie_name", "", time()-3600);
header("Location: http://mydomain.com/");
exit();
Your code is perfect but if you are facing some problem then please use this code when you are setting cookies.
Are you using both session and cookies?