Jump to content

Session not maintaining for the first time


rishibala143

Recommended Posts

Hi

 

I am developing a e-commerce website. The user logs in and buy a product when he checkout the page will redirect to the payment gateway. After the payment is completed it will return back to my website. This is ok. But when it is returning back the session maintained in my website get lost. This happen only for the first time. If the user again logged in and checkout the process works good and the session is maintaining.

 

Why does the session lost for first time.

 

I used session_start() in all the pages..

 

I cannot find the solutions. Kindly help..

 

Regards

P.Balakrishnan

Link to comment
Share on other sites

It's likely that the host-name/subdomain (www. vs no www.) in the URLs are changing back and forth (between having and not having the www. on them) and the session id cookie only matches the URL variation where it was set at and when you are redirecting around, including the return URL you tell your payment gateway to use, you finally end up going between pages that all have the same host-name (or lack thereof) in the URL.

 

If this is the case, here are some things you can do to fix the problem -

 

1) You should set up a .htaccess redirect to force all URL's to goto a single variation of your domain,

 

2) You should be constant in your code and in the return URL you give/configure your payment gateway to use to always build links/redirects with the same variation of your domain,

 

3) You should set the session.cookie_domain setting to be .yourdomain.com (with the leading dot . ) to get the session id cookie to match all variations of your domain.

Link to comment
Share on other sites

It's likely that the host-name/subdomain (www. vs no www.) in the URLs are changing back and forth (between having and not having the www. on them) and the session id cookie only matches the URL variation where it was set at and when you are redirecting around, including the return URL you tell your payment gateway to use, you finally end up going between pages that all have the same host-name (or lack thereof) in the URL.

 

If this is the case, here are some things you can do to fix the problem -

 

1) You should set up a .htaccess redirect to force all URL's to goto a single variation of your domain,

 

2) You should be constant in your code and in the return URL you give/configure your payment gateway to use to always build links/redirects with the same variation of your domain,

 

3) You should set the session.cookie_domain setting to be .yourdomain.com (with the leading dot . ) to get the session id cookie to match all variations of your domain.

 

 

Yes you are correct. The Problem is solved. Thanks for your help  :) :)

 

Regards

P.Balakrishnan

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.