Search code examples
phpsessionlogoutunset

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?


Solution

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