对于我的项目,我使用基于会话的访问控制来处理不同类型的用户,它安全吗?还有其他方法可以做同样的事情吗?这是我的编码。
// Note : $_SESSION['role']==1 refer to Admin and ['role']==3 refer to staff
session_start();
if(!empty($_SESSION['cur_user'])&&($_SESSION['role']==1) || ($_SESSION['role']==3) )
{
//if user login details is correct .. doing some stuff
?>
<!-- Website Content-->
<?php
}
else{
unset($_SESSION['cur_user']);
session_destroy();
header ("location:login.php");
}
?>