从支付提供商 codeigniter 重定向后会话丢失

Session lost after redirection from payments provider codeigniter

我们的一些客户遇到了一种奇怪的情况,他们丢失了会话数据。这总是在我们的支付提供商 ogone 重定向后发生。流程如下:

在调试这个问题时,我发现当用户从 ogone 重定向到应用程序时,会话数据丢失了。这种情况只会在 x 次请求时发生一次。所以当我在任何可能的浏览器中测试代码时,它似乎工作得很好。我没能在失败的付款和浏览器/付款方式/....

之间找到 link

这是我的会话配置:

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 172800;//48 hours
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = false;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

第一步是与银行确认卡

 try {
        $ch = curl_init();
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/xml', 'Content-length: ' . strlen($xml)));
                curl_setopt($ch, CURLOPT_POST, true); 
                curl_setopt($ch, CURLOPT_HEADER, false); 
                 curl_setopt($ch, CURLOPT_URL,'https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home/ThreeDModelPayGate'); 
                
                curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
                curl_setopt($ch, CURLOPT_COOKIESESSION, true);
               
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
                
                 curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
                $data = curl_exec($ch);
                curl_close($ch);
            } catch (Exception $e) {
                echo 'Caught exception: ', $e->getMessage(), "\n";
            }

访客导流到外部页面设置短信支付验证码 然后 第二步确认付款

 try {
                    
                    $ch = curl_init();
                    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/xml', 'Content-length: ' . strlen($xml)));
                    curl_setopt($ch, CURLOPT_POST, true); 
                    curl_setopt($ch, CURLOPT_HEADER, false); 
                  
                    curl_setopt($ch, CURLOPT_URL,'https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home/ThreeDModelProvisionGate'); //Baglanacagi URL
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
                  
                    curl_setopt($ch, CURLOPT_COOKIESESSION, true);
                   curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());

              

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
                $data = curl_exec($ch);
                curl_close($ch);
                
                $xxxml = new SimpleXMLElement($data);
            } catch (Exception $e) {
                echo 'Caught exception: ', $e->getMessage(), "\n";
            }

切换到第二步时,session数据丢失

你能帮忙吗

请注意,对于某些用户而言,此问题有时不会永久发生

header('Set-Cookie: ' . session_name() . '=' . session_id() . '; SameSite=None; Secure');