简体   繁体   English

session Codeigniter 支付网关返回 URL 数据为空

[英]session data empty on the payment gateway return URL in Codeigniter

There are several questions on this issue and I have tried most of the solutions suggested there, still I am unable to figure out the issue.关于这个问题有几个问题,我已经尝试了那里建议的大部分解决方案,但我仍然无法弄清楚这个问题。 I am using PayU payment API. Upon successful payment, the session data is empty on the RETURN URL. I had set only few fields in the session like user ID, product IDs in the cart我用的是PayU支付API。支付成功后,返回URL的session数据为空。我在session中只设置了几个字段,比如用户ID,购物车中的产品ID

Below is the return URL function:下面是返回 URL function:

public function payment_success() {
    echo "<pre>"; print_r($_SESSION);
    exit;
}

The output I see:我看到的 output:

    Array
(
    [__ci_last_regenerate] => 1600755715
)

Note that the session data persists while redirecting from function to function. Issue is only on the payment gateway's return URL function which is also in the same controller请注意,session 数据在从 function 重定向到 function 时仍然存在。问题仅出现在支付网关的返回 URL function 中,它也在同一个 controller 中

PHP Version:7.2.31 Codeigniter Version:3.1.11 PHP 版本:7.2.31 Codeigniter 版本:3.1.11

//My config.php: //我的配置.php:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

Possibilities I have tried as suggested我按照建议尝试过的可能性

//1
$config['sess_save_path'] = APPPATH.'ci_session/';

//2
$config['sess_expiration'] = 7200;

//3 in Session.php
// ini_set('session.name', $params['cookie_name']);
ini_set('session.id', $params['cookie_name']);

//4 tried under PHP versions 7.1 and 7.3

The issue was about "cookie SameSite attribute".问题是关于“cookie SameSite 属性”。 It is coming for Chrome version 84. Thanks to @04FS for the hint.它即将用于 Chrome 84 版。感谢@04FS 的提示。 Adding the below line in .htaccess worked for me在 .htaccess 中添加以下行对我有用

Header always edit Set-Cookie (.*) "$1; SameSite=None;Secure"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM