Lewis Smith Lewis Smith -4 years ago 61
PHP Question

PHP - Can't end session

I have a link in my website after login, that points to "index.php?logout=yes", then in my index.php I have the following code:

if ($_GET['logout'] == "yes") {
session_unset();
unset($_SESSION);
session_destroy();
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
$_SESSION = array();
$_SESSION = [];
}


Any ideas why it keeps you logged in and doesn't end the session?

Answer Source

Is this the first lines of code in your index.php if yes use header('Location: /'); instead of meta tag for refresh

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download