0

This might be slightly confusing, so please bear with me for a moment while i explain the issue.

I have a website www.mydomain.com and a mobile version m.mydomain.com The main website does not have any specific cookie_params set The mobile site specifically sets

session_set_cookie_params(0, '/', '.mydomain.com');

Mobile devices are auto-detected & directed to the mobile site.

The mobile site uses https://www.mydomain.com/mobile/ for the checkout so that the SSL cert is valid. So we are switching from m. to www. when we go secure.

Here is where the strangeness begins...

On my iPhone I can go through the whole process with no issues at all.

However, when I use a computer browser & specifically chose to use the mobile site, I cannot get into the checkout - the reason being is that the session_id is changing between m. & www. (& the database cannot find your basket items, so it won't let you in to the checkout) or rather that there are 2 sessions id's - one for www. & one for m.

Given that every page of the mobile site has the above param set, why is the computer browser opting to use the www. session id ?

Any suggestions to solve this greatly appreciated.

Additional info: I removed all cookies from firefox & restarted the browser. I went directly to m.mydomain.com & this works OK, am able to checkout.

So perhaps with this info the question becomes is there a way to force the mobile site - regardless of the URL - to use a specific cookie param name?

RiquezJP
  • 261
  • 3
  • 12
  • 1
    Shouldn't the main site have the same cookie params as the mobile site? Did you try doing that? – Jon May 11 '12 at 07:45
  • I am reluctant to do that because it is a high traffic site & since I am not really sure about why this is happening, it is a bad idea for a friday afternoon. – RiquezJP May 11 '12 at 07:46
  • Additional info: I removed all cookies from firefox & restarted the browser. I went directly to m.mydomain.com & this works OK, am able to checkout. – RiquezJP May 11 '12 at 07:47
  • Don't use cookies for session .. use Database sessions .. this way you cna make the user Log in on both mobile and web at the same time – Baba May 11 '12 at 08:29

1 Answers1

1
session_set_cookie_params(0, '/', '.'.str_replace('www.','',$_SERVER['HTTP_HOST']));
session_name('ses_name');
session_start();
YamahaSY
  • 289
  • 3
  • 17