javascript - Cannot read cookie in Internet Explorer from PHP when script is loaded from another domain -


ok, little complicated:

  1. i set cookie on domain foo.com php:

    header('p3p:cp="idc dsp cor adm devi taii psa psd ivai ivdi coni our ind cnt"'); setcookie("c", "value", strtotime( '+30 days' ));

  2. i call script <script src='http://foo.com/script.php'> domain bar.com loads javascript file output through php

    header('content-type: application/javascript');
    echo $_cookie['c'];

now, when open http://foo.com/script.php in chrome, firefox, edge or internet explorer, display value.
when instead load script bar.com, display value in chrome, edge(!) , firefox, in internet explorer 10/11, cookie not set , cannot read.

i not understand why cookie not set in ie since loading script foo.com cookie set initially. so, script should have access cookie.

any ideas highly appreciated.

what local domain names using call these scripts?

i remember ie peculiar domain names accepts cookies for, need contain @ least 1 dot . – names such localhost tend cause problems in regard.


Comments