$_SESSION['variable'] 不会取消设置或更改

$_SESSION['variable'] won't unset or change

$UserType = $row['UserType'];

$_SESSION['UserID'] = $row['UserID'];

//unset($_SESSION['UserType']);
$_SESSION['UserType'] = $UserType;
//unset($_SESSION['Dashboard']);
if ($UserType == 'read' OR 'edit' OR 'admin') {$_SESSION['Dashboard'] = 'YES';} 
else {$_SESSION['Dashboard']='NO';}

if ($_SESSION['Dashboard'] == 'YES') { ..... }

else 未达到.. 为什么?显然我也更喜欢 TRUE 或 FALSE

更改此行

if ($UserType == 'read' OR 'edit' OR 'admin') {$_SESSION['Dashboard'] = 'YES';} 

if ($UserType == 'read' OR $UserType =='edit' OR $UserType =='admin') {$_SESSION['Dashboard'] = 'YES';} 

您的 if 语句不正确。当前代码基本上是在比较 $UserType == 'ready' OR 'edit' is not 'empty', OR admin is not empty

你想要:

if ($UserType == 'read' OR $UserType == 'edit' OR $UserType == 'admin')

运行你检查得好

if ( ($UserType == 'read') OR ($UserType =='edit') OR ($UserType =='admin') ) {
$_SESSION['Dashboard'] = 'YES';
}else { 
$_SESSION['Dashboard']='NO';
}