Reputation: 4323
I'm having trouble resetting session variables in PHP. I'm now trying just testing resetting the session variable like this, but this doesn't even work:
session_start();
$_SESSION["name"] =false;
if (!isset($_SESSION["name"])) {
$message = getname(); //can't get this to ever be called
} else {
$message = welcome();
}
What am I missing here?
Upvotes: 3
Views: 815
Reputation: 2950
You want to unset the session variable
unset($_SESSION['name']);
Setting it to false
makes it so it's still set
(so isset
will still return true
), the only difference is that the actual value of the variable has changed to false
.
Upvotes: 7