这是我写的代码
if(!isset($_SESSION['authenticated'])){header("location:login.php");}
但是这个代码不工作,它正在被访问
能否将变量设置为真或假?
if ($_SESSION['authenticated']) {
// Admin page here...
} else {
// Redirect to another page...
header("Location: login.php");
die();
}
编辑:我说将其设置为true或false的原因是您可以通过将其设置为false来注销用户。而不是取消变量。
编辑:- 删除不需要的
= true
。
您在header函数中错过了大写L,您需要在重定向后杀死该页面。
代替header('location:index.php');
header("Location: login.php");
die();