【发布时间】:2018-02-25 17:18:47
【问题描述】:
奇怪的问题。
新开发的网站,使用使用会话的第 3 方登录系统(惊喜!)。网站在所有实例、所有浏览器上都能完美运行除了 Internet Explorer 11(可能还有以前的版本,未选中)。
预选赛:
- 我已经阅读了关于 SO 的各种相关主题,但没有任何内容符合要求。
- PHP
Header不会在每个受影响的页面上进行重定向 - 域名或网址中没有
_。 - 没有 iframe。
- 会话和域是安全的。
代码详情:
a)每个页面都有一个控制器文件,其中包含标题信息:
header("Cache-Control: no-cache, must-revalidate"); //HTTP 1.1
header("Expires: Thu, 19 Nov 2011 08:52:00 GMT"); // Date in the past
header('Content-Type: text/html; charset=utf-8');
header("X-Clacks-Overhead: GNU Terry Pratchett");
header_remove("X-Powered-By");
header("X-XSS-Protection: 1; mode=block");
header("X-Frame-Options: SAMEORIGIN");
header("X-Content-Type-Options: nosniff");
header("Content-Language: en");
header("Content-Security-Policy: upgrade-insecure-requests;");
header("Referrer-Policy: origin-when-cross-origin"); //referrer for Chrome
header("Referrer-Policy: strict-origin-when-cross-origin");
if (isset($_SERVER['HTTP_USER_AGENT']) &&
(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)){
header('X-UA-Compatible: IE=edge,chrome=1');
}
b) 作为此过程的一部分;执行 cookie 检查以了解是否在客户端浏览器上启用了 cookie。这是在两个登录/访问控制和公共站点区域完成的。
if($_COOKIE['cookieEnabled'] !== "yes") {
\setcookie('cookieEnabled', "yes", time() + 42000, "/", $_SERVER['HTTP_HOST'], true, true);
}
它就是一个 cookie,它说“是”,如果 cookie 尚未设置,则启用 cookie。简单的。
c) 在此之下;有控制器代码来加载会话变量并为第 3 方管理方面做其他事情。
// Create / Include the Session Object - Session.php
$session = new Session($db);
d) 我在Session.php __construct 中设置了一个测试语句来执行此操作:
session_start();
if($_COOKIE['cookieEnabled'] !== "yes" && empty($_SESSION)) {
error_log("INFO: An access attempt without a session or cookie was attempted...");
if($_COOKIE['cookieEnabled'] !== "yes"){
error_log("Cookie does not appear to be enabled");
}
die("unimportant debug error");
}
请注意,会话数组永远不会为空,因为它已预先填充在之前的页面中;
e) [本地] PHP.ini 是这样的:
session.cookie_secure=1
default.charset=utf-8
error_log=/home/domainaccount/error/PHP_error.log
session.save_path=/home/domainaccount/sessionz
session.cookie_domain=domain.org.uk
注意:网络路径为:
/home/domainaccount/public_html/
PHP.ini 值已通过phpinfo() 检查并正确设置。
奇怪的问题
我在各种浏览器中加载网站,它登录得很好,一切正常,会话数据被携带。
但在 IE11 上却没有。它只是返回一个空白屏幕、没有错误、没有反馈(也就是传递回登录页面的会话数据),并且没有基于代码的错误日志。
错误日志显示:
INFO:尝试了没有会话或 cookie 的访问尝试...
很多次,但没有迹象表明 cookie 被拒绝,只是会话。
不出所料,登录页面具有header 位置重定向,用于成功和失败的登录尝试。
关于 IE11
IE 版本号:11.248.16299.0。
IE cookie 设置:接受第一方 cookie,接受第三方 cookie,始终允许会话 cookie。
问题
1) 为什么这只发生在 IE 上?
2) 我该如何解决这个问题(更改我的标题、cookie 设置等?)
【问题讨论】:
-
这可能对stackoverflow.com/questions/18852767/… 有所帮助。您应该提供一个 P3P 标头来描述您的 cookie,以免它们被阻止。
-
我遇到了类似的问题,我的网站包含在另一个网站的 iframe 中,并且我们进行了 A2A 身份验证,会话 id cookie 丢失了。我的解决方案是在 apache 配置中将
Header set "P3P" 'CP="CAO PSA OUR"添加到 VirtualHost。 -
网站不在 iframe 中
标签: php session cookies internet-explorer-11