I have summarized the essence of the problem as brief as possible:
Simple script:
<?php
session_start();
$_SESSION['user']="logged";
then rewrite
$_SESSION['user']=0;
and show the contents of $ _SESSION
var_dump($_SESSION);
shows $ _SESSION ['user'] is '0' - sure since it has just been overwritten
BUT now look
if ($_SESSION['user']=="logged"){
echo "logged";
}
else{
echo "unlogged";
}
logged is output ....
It seems that changing the type of a variable is only superficial - I have no idea what I'm doing wrong. Do I need to use the comparison === to enable type checking?
source
share