Home >Backend Development >PHP Tutorial >Strange problem with session (already searched, but still can't solve it myself)_PHP Tutorial
Strange problem with session (already searched, but still can’t solve it myself)
My main login page is to determine whether to log in. Enter the address directly to avoid the login window. The first time it appears, you do not have permission to access, and admin|b:0 appears in the session file; refresh it once, and you have logged in
Notice: Undefined index: name in d:usrwwwhtmldengluindex.php on line 5
111122223333
The file in the session file becomes admin|b:1; the value of admin is 1. Strange! ! !
This is the code for index.php:
$admin=false;
if(isset($_SESSION['admin'])&&$_SESSION['admin']=true)
{ echo "You have logged in";
echo $_SESSION['name'];
}
else
{$_SESSION['admin']=false;
die("You don't have access");
header("Location:login.htm");
}
?>