Get cookies from another domain in IE

醉酒当歌 提交于 2020-02-06 07:34:41

问题


I've got the following:

User clicks on a link mydomain.com/redirect.php where gets a cookie (for mydomain.com) via setcookie function and then goes to another page (header('Location: ...');) - say lp.html

Then, on that page there is a script: gs('mydomain.com/getcookie.php', 'client=52', function() {}); and this function is as follows:

gs = function(path, args, fn) {
        var p = document.head || document.getElementsByTagName("head")[0]
        var s = document.createElement("script");
        p.appendChild(s);
        if (fn) {
            if (s.addEventListener) {
                s.addEventListener('load', fn, false);
            } else if (s.attachEvent) {
                s.attachEvent("onload", function() {
                    fn(window.event)
                });
            } else {
                s["onload"] = fn;
            }
            s.onreadystatechange = function() {
                fn()
            }
        }
        s.src = path + "?" + args;
}

The getcookie.php script gets a value from $_COOKIE (since it's on my domain) and returns a small js, like this: myParam = 'cookieValue'; for later use in js.

So, this works well... except Internet Explorer. It works there only if I manually allow it to accept all cookies.

answer: (thanks to duellsy)

adding

header('P3P: CP="CAO PSA OUR"');
header('P3P: CP="HONK"');

回答1:


IE has some cookie security things that can be hard to diagnose, try adding this to the top of your page

<?php header('P3P: CP="CAO PSA OUR"'); ?>

Look up Internet Explorer P3P, to find out more information on this

A good response on SO on 'what' this is: https://stackoverflow.com/a/5258105/1613391



来源:https://stackoverflow.com/questions/13473287/get-cookies-from-another-domain-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!