When setting false value to session, the session is set, but the value is empty. The type is boolean. This code:
<?php
session_start();
$_SESSION["IsMobile1"] = false;
$_SESSION["IsMobile2"] = true;
//header("location: ../../../index.php");
echo "IsSet1: " . isset($_SESSION["IsMobile1"]) . "; IsMobile1: " . $_SESSION["IsMobile1"] . "; type: " . gettype($_SESSION["IsMobile1"]) . ";<br>";
echo "IsSet2: " . isset($_SESSION["IsMobile2"]) . "; IsMobile2: " . $_SESSION["IsMobile2"] . ";<br>";
?>
prints out:
IsSet1: 1; IsMobile1: ; type: boolean;
IsSet2: 1; IsMobile2: 1;
My PHP version is 5.5.13. Is this expected behaviour? I am trying to read the session with code:
if (isset($_SESSION["IsMobile"]))
{
if (is_bool($_SESSION["IsMobile"]))
{
header("location: Mobile/");
exit;
}
}
but of course it is not working, because IsMobile is empty boolean. (In original I just use IsMobile. IsMobile1 and IsMobile2 is just for testing).