Report this

What is the reason for this report?

PHP session cookies in a subdomain using IE11/Safari

Posted on December 21, 2014

I’m losing the session between redirects in both Internet Explorer 11 and Safari (works fine on Chrome, Opera and Firefox).

When I try to login using www.subdomain.domain.com the error occurs on IE/Safari, but even on them it works fine if I use the IP (xxx.xxx.xxx.xxx/folder).

I’m trying to setup the session like:

session_name("somename");
session_set_cookie_params(3600, '/folder/');
session_start();

I have already tried:

session_set_cookie_params(3600, '/folder/', '.domain.com);
session_set_cookie_params(3600, '/folder/', '.subdomain.domain.com);
session_set_cookie_params(3600, '/folder/', 'domain.com);  <-- without the preceding dot
session_set_cookie_params(3600, '/folder/', 'subdomain.domain.com);
ini_set("session.cookie_domain", ".domain.com"); <-- before set_cookie_params

But none of them seems to work.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I am not able to speak to Safari but IE11 and Edge have removed some cross domain functionality intentionally. More information about this change can be found here and here.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.