Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session variables not resetting

Tags:

php

session

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?

like image 250
jonmrich Avatar asked Sep 28 '26 14:09

jonmrich


1 Answers

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.

like image 191
Alex Santos Avatar answered Oct 02 '26 04:10

Alex Santos