- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我继承了一个使用 SagePay Direct 进行支付的 Opencart 2.0.1.1 网站。
随着 Chrome 80 交易中相同站点 cookie 的更改,无法正确回调 - 未找到交易。付款通过,但似乎 session /交易引用丢失,因此订单状态不会更新。我认为这是因为 cookie 的处理方式发生了变化,并且重定向到 3D 安全屏幕打破了这一点。
我已将 session cookie 更新为 samesite=None 并将其设置为安全,但这并没有解决问题。目前支付可以在其他浏览器中使用,并且当使用网站的本地开发副本和 SagePay 的测试服务 Chrome 运行时也可以使用。
有没有其他人遇到过这个问题并知道修复方法?
我不认为更新 OpenCart 是一个可行的选择,因为一些核心文件已经被以前的开发人员调整过,但我不知道是哪个。
最佳答案
解决方案:
首先,请确保您使用的 php 版本是 7.3 或更高版本。对于这个方案,至少需要7.3版本,但是如果你使用的是低版本,你可以通过查看我提供的源代码来更改代码,我没有添加它,因为我无法测试它。再次,我应该提到我在 Opencart 2.3 版本上尝试过这个解决方案,它没有任何问题。我将在下面提供详细信息,但通常我已经通过在 session_start() 和 setcookie() 命令之前添加“相同站点”=>“无”和安全参数来解决它。
1. system/library/session.php
找:
session_set_cookie_params(0, '/');
session_start();
代替:
if (PHP_VERSION_ID < 70300) {
session_set_cookie_params(0, '/; samesite=None', '.yoursite.com', true, true);
} else {
ini_set('session.cookie_samesite', 'None');
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'domain' => '.yoursite.com',
'secure' => true,
'httponly' => true,
'samesite' => 'None'
]);
}
session_start();
找:
if ($key != 'PHPSESSID') {
setcookie($key, $this->session_id, ini_get('session.cookie_lifetime'), ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure'), ini_get('session.cookie_httponly'));
}
代替:
if (PHP_VERSION_ID < 70300) {
setcookie($key, $this->session_id, ini_get('session.cookie_lifetime'), ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure'), ini_get('session.cookie_httponly'));
} else {
$samsite_cookie_options = array (
'expires' => ini_get('session.cookie_lifetime'),
'path' => ini_get('session.cookie_path'),
'domain' => ini_get('session.cookie_domain'),
'secure' => true, // or false
'httponly' => true, // or false
'samesite' => 'None' // None || Lax || Strict
);
setcookie($key, $this->session_id, $samsite_cookie_options);
}
找:
setcookie($key, '', time() - 42000, ini_get('session.cookie_path'), ini_get('session.cookie_domain'));
代替:
if (PHP_VERSION_ID < 70300) {
setcookie($key, '', time() - 42000, ini_get('session.cookie_path'), ini_get('session.cookie_domain'));
} else {
$samsite_cookie_options = array (
'expires' => time() - 42000,
'path' => ini_get('session.cookie_path'),
'domain' => ini_get('session.cookie_domain'),
'secure' => true, // or false
'httponly' => true, // or false
'samesite' => 'None' // None || Lax || Strict
);
setcookie($key, '', $samsite_cookie_options);
}
2.目录/ Controller /startup/startup.php
setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
代替:
if (PHP_VERSION_ID < 70300) {
setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
} else {
$samsite_cookie_options = array (
'expires' => time() + 60 * 60 * 24 * 30,
'path' => '/',
'domain' => $this->request->server['HTTP_HOST'],
'secure' => true, // or false
'httponly' => true, // or false
'samesite' => 'None' // None || Lax || Strict
);
setcookie('language', $code, $samsite_cookie_options);
}
找:
setcookie('tracking', $this->request->get['tracking'], time() + 3600 * 24 * 1000, '/');
代替:
if (PHP_VERSION_ID < 70300) {
setcookie('tracking', $this->request->get['tracking'], time() + 3600 * 24 * 1000, '/');
} else {
$samsite_cookie_options = array (
'expires' => time() + 3600 * 24 * 1000,
'path' => '/',
'domain' => $this->request->server['HTTP_HOST'],
'secure' => true, // or false
'httponly' => true, // or false
'samesite' => 'None' // None || Lax || Strict
);
setcookie('tracking', $this->request->get['tracking'], $samsite_cookie_options);
}
找:
setcookie('currency', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
代替:
if (PHP_VERSION_ID < 70300) {
setcookie('currency', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
} else {
$samsite_cookie_options = array (
'expires' => time() + 60 * 60 * 24 * 30,
'path' => '/',
'domain' => $this->request->server['HTTP_HOST'],
'secure' => true, // or false
'httponly' => true, // or false
'samesite' => 'None' // None || Lax || Strict
);
setcookie('currency', $code, $samsite_cookie_options);
}
3. 搜索所有文件并更改 session_start() 和 setcookie() 命令,如上所述。实际上,前两个文件的更改已经足够了,但我仍然建议扫描您的其他文件以避免任何意外。
关于php - SagePay/Chrome 80/3D Secure/Samesite 和丢失的 session ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61462635/
我在 Ubuntu 10.04 LTS 上运行 Eclipse Galileo。今天 Ubuntu 在我身上崩溃了,重新启动后,我发现 Eclipse 已经完全失去了 Java Perspective
我使用配置了 sonata_user 的 SonataAdminBundle在 config.yml : sonata_user: impersonating: route:
我有 ubuntu 14.04 但它不见了 docker exec sudo docker exec -it ubuntu_bash bash 我希望在现有正在运行的 docker 容器中运行交互式
我正在使用 Ubuntu 8.04/32 位(作为虚拟机)。在一个不是 min 的项目上执行一些 make 时,我得到了错误: g++:/usr/lib/libstdc++.a: 没有这样的文件或目录
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为
我正在尝试获取有关我在 UIImagePicker 中选择的视频的一些数据。 因此,当它进入 UIImagePicker 委托(delegate)方法(如下)时,我知道我需要使用信息字典中的 UIIm
我的网站最近被可能的黑客行为删除了。我上传了备份的文件夹和数据库,但现在我的 View 没有显示。其他一切都有效。我想不出有什么变化,只是上传了几天前的备份。 这些字段在 admin/build/vi
我执行以下操作来设置我的 session ,这是有效的,因为 echo 出现了。但是当我转到下一页或另一页时, session 不存在吗?我做错了什么? $session_start(); if ($
我试图在 BigQuery 中使用这段代码,显然是从 GA 中获取数据,但 _TABLE_SUFFIX 似乎有问题。错误显示“错误:无法识别的名称:_TABLE_SUFFIX at [12:3]”您能
输入:8(2 5 6 9 10 2 7 4)预期输出:(2 7 9 9 12 5 7 6)实际输出:(2 7 9 9) 这是我的大学作业,也是我第一次在这里提问。我不知道为什么,但 10 没有扫描,有
$('div'); // 我在上面的代码中遇到错误。在检查 .js 代码时,我找不到名为 $ 的函数,但根据文档,应该有一个。 最佳答案 试试 http://ajax.googleapis.co
以下简单代码的输出对我来说有点奇怪。它错过了在控制台上打印的 0 到 100 之间的一些数字。 谁能解释一下为什么省略打印?我对并发编程完全陌生。 import java.util.concurren
我正在学习 xamarin 以构建移动应用程序,但我对 Xamarin 和移动应用程序一无所知。我打开了一个空白的移动应用程序,其中有“Hello world”示例并编辑了一些文本,但我的应用程序图标
我正在将一些值存储到 sqlite 数据库中。因此,数据是作为字符串从文本字段收集的,然后转换为 double 并持久化。 这是我试过的 NSDecimalNumber 答案; value.answe
我有一个奇怪的案例。突然,其中一个表中的一些记录(这么多记录)丢失了。首先,我认为这是由我的 PHP 脚本中的错误引起的。但是,我检查了一下,我的脚本中没有DELETE操作,只有UPDATE。有谁知道
我正在复制 NSString来自 NSDictionary进入本地NSString使用 [[NSString alloc] initWithString:] ,对其进行处理(删除一些字符),然后将其发
当保存在根文件夹中时,我的非常基本的 html 页面保持样式。为一个组创建了一个新文件夹,但是当我将页面移动到该文件夹时,它们似乎失去了与 css 文件的连接。 认为问题可能出在链接上,因为它现在
我需要使用 OpenCV 训练一些图像。但问题是,我找不到 opencv_createsamples 程序。我以正常方式安装了 OpenCV,因为我使用的是 Windows 7。这个 opencv_c
我有一个绑定(bind)到 JTable 的 ArrayList。之后 bindingGroup.unbind(); bindingGroup.bind(); (完成刷新数据)我丢失了表格单元格渲
所以基本上我们只是丢失了一个 keystore 和备份 keystore 。但是我们可能知道原始 keystore 的密码。 我的问题是,如果我们知道原始 keystore 的密码,我们可以重新生成
我是一名优秀的程序员,十分优秀!