Internet Explorer 8 doesn't pass session cookie for ajax request

前端 未结 5 1200
半阙折子戏
半阙折子戏 2021-01-05 13:37

I have simple php application, it works on all browsers except on IE8 beta 2, problem occurs when I try to update table field using Ajax call (jQuery post method). Using IE8

5条回答
  •  星月不相逢
    2021-01-05 14:22

    Yesterday I had similar problem and found the solution. I hope this will help someone else also.

    Problem: Suppose there's a website www.somewebsite.com and IFRAME inside it whcih loads php file from my server, www.myserver.com/welcome.php. Website was loading successfully as well as my welcome page and it showed something like "Hello Bob", so it successfully found user and logged him in.

    Afterwards my JavaScript was making AJAX calls to another PHP file, and response was kind of in "not authorized" state, so SESSION data was completely missing. After page refresh, everything was working correctly. And this was happening only under IE8!

    I thought that problem was with sending session cookies to the server, but when I installed Fiddler, I found that IE8 was sending cookies as well as PHPSESSID correctly, but server was kind of unable to detect correct SESSION object. Another strange thing was that 2nd time server sent following header:

    P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"

    but first time no. After adding that header manually in PHP script, everything worked like a charm!

    Then, when I googled that "p3p abracadabra", I found following web site:

    http://adamyoung.net/IE-Blocking-iFrame-Cookies

    Conclusion: Make sure that you're sending the header on every page that sets a cookie.

    And this is not only related to IE8 + PHP combination, same problem happens in case of IE8 + ASP.NET, IE8 + JSP, etc.

提交回复
热议问题