When the user clicks a logout button, I connect to a script that simply does this
session_destroy();
session_start();
I thought this would be enough to reset all $_SESSION variables such as $_SESSION['logged'] and $_SESSION['username'] but when I load the page again, it automatically logs me in as if the session is still active.
As the documentation explains:
It also gives an example of how to do so:
Just clearing the array is sufficient to log the user out; they’ll still have the same session ID, but
$_SESSIONwill be empty, so$_SESSION['logged']and$_SESSION['username']won’t exist