dqc18251 2015-02-24 03:12
浏览 57
已采纳

Paypal REST API返回页面

I'm currently using the Paypal REST API to process billing agreements for users with multiple plans.

When a user signs up for a plan, it takes them to PayPal to pay. After they finish that step, PayPal redirects them to a return URL that I have supplied.

The problem is, sometimes the user's session does not persist when they return from PayPal!

I have session_start() as the first line in all of my files, so the sessions are being created. I have verified, before taking the user to PayPal, that the $_SESSION array is being populated - it's just when they are brought back after PayPal.

Is there a better way to persist data like that so I can update a users account on return back from PayPal? Or maybe there is a way to pass the email with the PayPalrequest so that it is returned in the object they send back to my website on return?

  • 写回答

2条回答 默认 最新

  • doudouchan5830 2015-02-25 17:06
    关注

    If you're properly starting the session via session_start() on both your sign-up page and the page that PayPal redirects back to, your session should be starting properly.

    Assuming that you're not inadvertently closing the session, or regenerating the ID, it sounds like there isn't an actual "session management" issue, but perhaps it has to do with the URL that PayPal is redirecting back to.

    A common issue with PHP sessions is that, with a default PHP config, they don't carry between subdomains.

    For example, if I visit your domain domain at example.com, my session will only be active on example.com. If I then go to www.example.com, I will receive a new session.

    You can verify this by going to your site at example.com or www.example.com and checking what domain the PHPSESSID cookie is set for. If it is not .example.com (note the leading .), then this is the issue =]

    To help resolve this, you can modify your server's config to set the .example.com as the cookie's domain. Taken from this answer:

    session.cookie_domain = ".example.com"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?