【发布时间】:2019-02-26 07:23:54
【问题描述】:
这是一个多星期以来的问题,我开始相信它与代码以外的东西有关!
这是我的会话页面:
<?php
session_start();
include('dbConfigBDO.php');
include('SafeRedirect.php');
if(!isset($_SESSION['login_user'])){
safe_redirect('login.php');
die();
}
?>
我在登录后设置$_SESSION['login_user'] 并在每个页面中调用session.php。我还有一个注销页面:
<?php
session_start();
require 'SafeRedirect.php';
unset($_SESSION['login_user']);
session_destroy();
safe_redirect('login.php');
?>
即使在注销后我仍然可以访问我试图通过使用会话来阻止的页面。
可能有什么问题?
编辑:我的SafeRedirect.php 页面,我从here 使用它
<?php
function safe_redirect($url, $exit=true) {
if (!headers_sent()){
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);
header("Connection: close");
}
print '<html>';
print '<head><title>Redirecting you...</title>';
print '<meta http-equiv="Refresh" content="0;url='.$url.'" />';
print '</head>';
print '<body onload="location.replace(\''.$url.'\')">';
print 'You should be redirected to this URL:<br />';
print "<a href=$url>'$url'</a><br /><br />";
print 'If you are not, please click on the link above.<br />';
print '</body>';
print '</html>';
if ($exit) exit;
}
?>
【问题讨论】:
-
你能发布 SafeRedirect.php 的内容吗?
-
我做了,感谢您的编辑!
-
老实说,我没有看到问题..
-
对我来说也一样,真正的问题是它曾经在另一个项目中工作:/