<bdo id='aR7jZ'></bdo><ul id='aR7jZ'></ul>

    <legend id='aR7jZ'><style id='aR7jZ'><dir id='aR7jZ'><q id='aR7jZ'></q></dir></style></legend>
    1. <i id='aR7jZ'><tr id='aR7jZ'><dt id='aR7jZ'><q id='aR7jZ'><span id='aR7jZ'><b id='aR7jZ'><form id='aR7jZ'><ins id='aR7jZ'></ins><ul id='aR7jZ'></ul><sub id='aR7jZ'></sub></form><legend id='aR7jZ'></legend><bdo id='aR7jZ'><pre id='aR7jZ'><center id='aR7jZ'></center></pre></bdo></b><th id='aR7jZ'></th></span></q></dt></tr></i><div id='aR7jZ'><tfoot id='aR7jZ'></tfoot><dl id='aR7jZ'><fieldset id='aR7jZ'></fieldset></dl></div>

      <small id='aR7jZ'></small><noframes id='aR7jZ'>

    2. <tfoot id='aR7jZ'></tfoot>

      为什么我的 PHP 会话会死掉?为什么我不能恢复它们?

      时间:2023-06-23

        <tbody id='vnqTi'></tbody>
      <i id='vnqTi'><tr id='vnqTi'><dt id='vnqTi'><q id='vnqTi'><span id='vnqTi'><b id='vnqTi'><form id='vnqTi'><ins id='vnqTi'></ins><ul id='vnqTi'></ul><sub id='vnqTi'></sub></form><legend id='vnqTi'></legend><bdo id='vnqTi'><pre id='vnqTi'><center id='vnqTi'></center></pre></bdo></b><th id='vnqTi'></th></span></q></dt></tr></i><div id='vnqTi'><tfoot id='vnqTi'></tfoot><dl id='vnqTi'><fieldset id='vnqTi'></fieldset></dl></div>

    3. <small id='vnqTi'></small><noframes id='vnqTi'>

        <tfoot id='vnqTi'></tfoot>
      • <legend id='vnqTi'><style id='vnqTi'><dir id='vnqTi'><q id='vnqTi'></q></dir></style></legend>

              <bdo id='vnqTi'></bdo><ul id='vnqTi'></ul>

                本文介绍了为什么我的 PHP 会话会死掉?为什么我不能恢复它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个使用 PHP 和 PayPal API 的应用程序.获取付款的基本方式是您对 PayPal 进行 Web 服务调用以获取令牌,然后使用该令牌将浏览器重定向到 PayPal 以供用户支付.确认付款详细信息后,PayPal 会重定向回您最初在服务调用中设置的 URL.

                I have an app using PHP and the PayPal API. The basic way it works to get a payment is that you do a web service call to PayPal to get a token and then do a browser redirect to PayPal with that token for the user to pay. After the payment details have been confirmed, PayPal redirects back to the URL you originally set in the service call.

                这一切都有效,每天有数百万人使用它,等等.

                This all works, millions of people use it every day, et cetera.

                奇怪的是,当 PayPal 重定向回来时,PHP 会话消失了.这是一个有据可查的问题.

                Strange thing is, when PayPal redirects back, the PHP session is gone. It's a well-documented issue.

                第一个问题:为什么会这样?两个页面都在同一个域中,都使用 HTTPS.该会话适用于所有请求,直到 PayPal 重定向回来.

                First question: why is this happening? Both pages are on the same domain, both use HTTPS. The session works for all requests up until the PayPal redirect back.

                链接的论坛帖子提出了一种解决方法,将会话 ID 保留在 PayPal 请求中,然后稍后检索它并恢复会话.很好,但它似乎不起作用.

                The linked forum thread suggests a workaround, to persist the session ID in the PayPal request and then to retrieve it later and restore the session. Great, except it doesn't seem to work.

                我可以添加一些日志语句:

                I can add some log statements:

                log(session_id());
                

                在各种重定向之前和之后.从 PayPal 回来后,我又记录了一些.

                before and after the various redirects. When coming back from PayPal, I log some more.

                log("session id is " . session_id());
                $session_id = get_session_id_from_paypal();
                log("setting it back to " . $session_id);
                session_id($session_id);
                session_start();
                log("session id is now " . session_id());
                

                结果完全不是我所期望的:

                The result is not at all what I'd expect:

                session_id 是 fc8f459a186a3f4695ff9ac71b563825
                将其设置回 82460dcf8c8ddd538466e7cb89712e72
                session_id 现在是 360ba3fd99d233e0735397278d2b2e55

                session_id is fc8f459a186a3f4695ff9ac71b563825
                setting it back to 82460dcf8c8ddd538466e7cb89712e72
                session_id is now 360ba3fd99d233e0735397278d2b2e55

                第二个问题:为什么会话 ID 根本不是我设置的?我究竟做错了什么?或者,至少,为什么没有一个会话变量返回?

                Second question: why is the session id not at all what I set it to? What am I doing wrong? Or, at least, why do none of the session variables come back?

                推荐答案

                只是一个想法...

                您是否将 session.referer_check 设置为您的主机?默认值为空字符串,但它可能已更改...当页面从 PayPal返回"时,php 将删除会话信息.

                Do you have session.referer_check set to your host perhaps? The default is the empty string, but it might have been changed ... and when the page 'comes back' from PayPal, php will trash the session info.

                你可以用phpinfo()检查session.referer_check.

                You can check the session.referer_check with phpinfo().

                这篇关于为什么我的 PHP 会话会死掉?为什么我不能恢复它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Paypal IPN 获得空白确认(应为“已验证"或“无效") 下一篇:PHP 付款中的 Paypal API Express Checkout 错误代码 13113

                相关文章

                <i id='IkOU9'><tr id='IkOU9'><dt id='IkOU9'><q id='IkOU9'><span id='IkOU9'><b id='IkOU9'><form id='IkOU9'><ins id='IkOU9'></ins><ul id='IkOU9'></ul><sub id='IkOU9'></sub></form><legend id='IkOU9'></legend><bdo id='IkOU9'><pre id='IkOU9'><center id='IkOU9'></center></pre></bdo></b><th id='IkOU9'></th></span></q></dt></tr></i><div id='IkOU9'><tfoot id='IkOU9'></tfoot><dl id='IkOU9'><fieldset id='IkOU9'></fieldset></dl></div>

                1. <legend id='IkOU9'><style id='IkOU9'><dir id='IkOU9'><q id='IkOU9'></q></dir></style></legend>
                2. <small id='IkOU9'></small><noframes id='IkOU9'>

                  <tfoot id='IkOU9'></tfoot>

                    <bdo id='IkOU9'></bdo><ul id='IkOU9'></ul>