Reputation: 7688
I have this next function:
function checkLoggedIn($status, $redirect=TRUE){
switch($status){
case "yes":
if(!isset($_SESSION["loggedIn"])){
if($redirect) {
header("Location: login.php");
exit;
} else {
$authenticated = false;
}
} else {
checkLoggedIn("no");
}
break;
case "no":
if(isset($_SESSION["loggedIn"]) && $_SESSION["loggedIn"] === true ){
$authenticated = true;
}
break;
}
var_dump($authenticated);
return $authenticated;
}
The strange this is that when I enable var_dump($authenticated);
, I get as output if true
:
bool(true)
NULL
and just
bool(false)
if false
Any ideas why?
Upvotes: 0
Views: 63
Reputation: 18706
That's because you are calling checkLoggedIn()
inside itself.
Upvotes: 3