我有一个令人困惑的问题。我正在为网站构建登录系统,并且仅在 IE 9 中的一个用户计算机上,登录脚本失败。我已经使用 Fiddler 检查是否正在发送正确的 POST 数据。我会更多地使用那台计算机,但我没有那个机会。
我知道正在发送正确的登录详细信息;当发送不正确的登录详细信息时,PHP 脚本会发出正确的错误,并且所有帐户的登录都失败。登录系统使用 PHP 会话。我对此完全感到困惑,从未见过这样的事情。
位于gatewaymma.com的站点我设置了一个没有任何特殊访问权限的测试帐户:
用户名:testAcc
密码:test22
同样,这只发生在 IE 9 中,没有其他浏览器,并且只在一台机器上(win 7),所以我无法复制它,据我所知,收到了正确的 $_POST 数据。
如果有人可以复制这一点或给出他们看到的可能导致这种情况的可能区域,将不胜感激。
我曾认为 cookie 安全性可能会导致问题,但在添加了对 cookie 的检查后,没有产生任何错误。
这是登录脚本的一部分:
if(/* the password was correct, there is def no problem here*/){
session_regenerate_id(true);
$_SESSION['logged'] = true;
/*set other session vars*/
DB::query("UPDATE fa_logged_ips SET tries = 0, next_try = 0 WHERE ip = %s LIMIT 1", $_SESSION['ip']);
DB::query("UPDATE fa_users SET last_login = $_SESSION[last_activity] WHERE ID = %s LIMIT 1", $_SESSION['uid']);
}
}
//If the login was not successful (this error message is not fired, so I don't believe the session is being lost somewhere after this point
if($_SESSION['logged'] !== TRUE){
$fArray['loginErr'] = "The username and password combination you entered is not valid.";
check_ip();
}
请注意,脚本的最后一部分检查用户是否已登录,这意味着会话已成功创建,但是当用户被重定向到主页时它会以某种方式丢失。
编辑:还有一件事,这个登录系统源自我在网站的另一部分(在子域上)启动的系统,该系统在同一台计算机上运行良好,并且在过去 5 个月内一直如此。
编辑:
if(!isset($_SESSION['logged'])){
formatSession();
setcookie('cookieTest', '1', time()+3600*24*30); //set a cookie that will be checked for later
$ip = $_SERVER['REMOTE_ADDR']; //Get the user's ip address
//Check if the IP is logged in the system
$logged_ip = DB::queryFirstRow("SELECT * FROM fa_logged_ips WHERE ip = %s", $ip);
//if so
if(!empty($logged_ip)){
//if ip has too many failed logins
if ($logged_ip["tries"] < $login_attempt_limit) {
$_SESSION['next_try'] = $logged_ip["next_try"]; //store when their lockout ends
}
else {
$_SESSION['next_try'] = 0; //otherwise they may try to log in at their discretion
}
$_SESSION['tries'] = intval($logged_ip["tries"]); //store how many login tries the ip has
}
}
The session format funciton
function formatSession(){
global $sysEnable;
$_SESSION['logged'] = false; //The user is not logged in
$_SESSION['sysEnable'] = $sysEnable;//Store wether or not the system is accessible
}
编辑
我强烈认为这与 IE 中的某种安全设置有关,因为我只看到它发生在一台计算机上,并且无法在任何其他计算机上复制它。另外我可以通过打开cookie安全来产生类似的效果,但是如前所述,cookie检查在计算机上是成功的
编辑 9/1
我认为 IE 可能无法维持会话;IE 没有保存会话 ID。同样,我无法复制这种行为,所以在我可以使用那台计算机之前不能100%肯定。