Sugitime
Sugitime

Reputation: 1888

Redirect to PayPal breaks sessions

I am running into an issue with a redirect and sessions.

The flow of the applications is this:

Customer goes to site Adds product to cart Selects to checkout with PayPal Is redirected to PayPal Logs in to PayPal Redirected back to site Continues through billing/shipping pages Confirms the order and submits

This is working in development without an issue.

When I go to the live server, the session keeps getting lost after the redirect to PayPal.

Any idea what it could be?

Extra Info:

I found that when I first go to the website, I have a session ID.

When I go through the checkout process and I am redirect to PayPal, then directed back to the return URL (back to the merchant website), the same session ID is in the cookie. So it looks like the session is not being restarted, but rather that the session data is just empty.

Upvotes: 3

Views: 3197

Answers (3)

Shijesh GLmn
Shijesh GLmn

Reputation: 31

in php.ini, set session.cookie_domain= '.yourdomain.com'; or if you don't have access to it change domain parameter

session_set_cookie_params ( lifetime,'/','.yourdomain.com',false);

note that you have to call it before session_start();

this would share the session over all subdomains including www.domain.com, this solved my problem. this has the advantage that we need not worry whether user typed www.domain.com or simply domain.com to access the page.Hope this helps

Upvotes: 0

AdiechaHK
AdiechaHK

Reputation: 466

I have same issue, and I found that it's mistake in domain name, as before redirecting to paypal url is

'http://www.example.com/paypal-redirect.php'

while at the time of return from paypal url is

'http://example.com/paypal-return.php'

so here I missed www, so it might be that, or http/https just do check that thing, hope that will help to resolve this issue

Upvotes: 4

shauvik
shauvik

Reputation: 3922

Are you calling session_start() on the page that returns from Paypal?

That is usually the common mistake. http://www.w3schools.com/php/php_sessions.asp

Upvotes: 1

Related Questions