从付款网关退回时,Chrome丢失了我的会话数据

时间:2020-08-30 16:36:14

标签: javascript php forms session payment-gateway

自8月初以来,我的用户目前每当使用Chrome浏览器向Moneris进行付款时,都失去会话。在Firefox下工作正常。自几年以来,代码一直没有改变,它们都是自动开始的。

付款“ summary.php”页面最初调用网关URL,然后在交易后返回“ return.php”页面。该返回页面仅包含用于获取交易密钥并将其发布回网关以进行验证的表单:

api

这里的问题是,调用此页面时,所有会话数据都消失了。我也无法将会话存储在任何地方,因为网关无法将我发回的信息发回给我。

恐怕可能与7月发布的Chrome有关,该Chrome在注释中包含以下内容: “相同的站点Cookie政策更改开始再次推出”

与8月发行版相同: “拒绝不安全的SameSite = None cookie”,但我不知道如何/在何处进行处理。

该网站托管在CPANEL上,我确保用户一直使用HTTPS。

有人有建议吗?

编辑:

我刚刚注意到,当我登录和退出网站时,会得到很多这样的信息:

“在https://google.com/处设置了与跨站点资源关联的cookie,但未设置<?php session_start(); ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <script> function verify_transaction() { document.getElementById('verify').submit(); } </script> </head> <body onload="verify_transaction()"> <form id="verify" name="verify" action="https://www.gateway.com/verify.php" method="post"> <input type="hidden" name="ps_store_id" value="abcdef"> <input type="hidden" name="hpp_key" value="abcdef"> <input type="hidden" name="transactionKey" value="<?php echo $_POST['transactionKey'] ?>"> </form> </body> </html> 属性。由于Chrome现在仅在设置了具有跨站点请求的cookie的情况下会被阻止与SameSiteSameSite=None一起使用。您可以在开发人员工具的“应用程序”>“存储”>“ Cookies”下查看Cookie,并在https://www.chromestatus.com/feature/5088147346030592https://www.chromestatus.com/feature/5633521622188032."

上查看更多详细信息。

1 个答案:

答案 0 :(得分:0)

<?php
session_start();
if(isset($_POST['transactionKey'])) {
    $_SESSION['transKey'] = $_POST['transactionKey']; 
}
?>

<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <script>
            function verify_transaction() {
                document.getElementById('verify').submit();
            }
        </script>
    </head>
    
    <body onload="verify_transaction()">
        <form id="verify"  name="verify" action="https://www.gateway.com/verify.php" method="post">
            <input type="hidden" name="ps_store_id" value="abcdef">     
            <input type="hidden" name="hpp_key" value="abcdef">
            <input type="hidden" name="transactionKey" value="<?php echo $_SESSION['transKey']; ?>">
        </form>
    </body>
</html>

验证后销毁会话。