【问题标题】:Session lost after redirection from payments provider codeigniter从支付提供商 codeigniter 重定向后会话丢失
【发布时间】:2020-12-26 03:43:19
【问题描述】:

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

  • 用户正在完成订单

  • 用户决定通过ogone付款。

  • 之后,用户被重定向到应用程序的支付成功/错误处理程序。

在调试此问题时,我发现当用户从 ogone 重定向到应用程序时会话数据丢失。这仅在 x 数量的请求上发生一次。因此,当我在任何可能的浏览器中测试代码时,它似乎工作得很好。我没有找到付款失败和浏览器/付款方式/ ....之间的链接。

这是我的会话配置:

$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";
            }

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

你能帮忙吗

请注意,某些用户有时不会永久出现此问题

【问题讨论】:

  • 您能确认一下您的 CI 版本吗?报告了早期 3.x 版本的一些会话问题
  • ci-version = 3.1.11

标签: php curl codeigniter-3 libcurl php-curl


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-14
    • 1970-01-01
    • 2014-03-21
    • 1970-01-01
    • 2013-01-06
    • 2012-08-17
    • 2017-02-06
    • 2020-11-11
    相关资源
    最近更新 更多