Reputation: 11382
Ok, this is a little complicated:
I set a cookie on domain foo.com
with php:
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
setcookie("c", "value", strtotime( '+30 days' ));
I call the script <script src='http://foo.com/script.php'>
from domain bar.com
that loads a javascript file that is output through php
header('Content-Type: application/javascript');
echo $_COOKIE['c'];
Now, when I open http://foo.com/script.php
in Chrome, Firefox, Edge or Internet Explorer, it will display value
.
When I instead load the script from bar.com
, it will also display value
in Chrome, Edge(!) and Firefox, but in the Internet Explorer 10/11, the cookie is not set and cannot be read.
I do not understand why the cookie is not set in IE since I am loading the script from foo.com
where the cookie was set initially. So, the script should have access to the cookie.
Any ideas highly appreciated.
Upvotes: 0
Views: 440
Reputation: 96412
What local domain names are you using to call these scripts?
I remember that IE is sometimes peculiar about domain names it accepts cookies for, they need to contain at least one dot .
– names such a localhost
tend to cause problems in that regard.
Upvotes: 1