我正在创建一个小网站,我想知道因为我有一些关于http标头的课程,使用这样的日志记录算法是否安全:
if(! isset($_SESSION["user"]) {
header("location : logout.php");
}
// and here i start my web page if the conditin above is not satisfied
<html> ........
我认为这不是因为 Web 客户端可以忽略重定向,不是吗?
重定向
后退出时它是"安全的" - 如果重定向不起作用:
if(! isset($_SESSION["user"]) {
header("location : logout.php");
exit("you are not authorized!");
}
// and here i start my web page if the conditin above is not satisfied
<html> ........
最好添加一个"else"语句,以防止错误拖钓你:)
if(!isset($_SESSION["user"]) {
header("location : logout.php");
exit("you are not authorized!");
} else { ?>
<html>...</html>
<?php } ?>