IE8不及格的ajax请求的会话cookie [英] Ie8 doesn't pass session cookie for ajax request

查看:228
本文介绍了IE8不及格的ajax请求的会话cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有简单的PHP应用程序,它适用于所有的浏览器除了在IE8正式版2,当我尝试使用Ajax调用(jQuery的POST方法)来更新表中的字段出现问题。使用IE8的调试我的数字指出,IE8的不发送会话cookie,以便PHP脚本重定向到登录而不是执行请求的操作页面。

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 debugger I figure out that IE8 doesn't send session cookie so php scripts redirects to login page instead of executing requested action.

我能做些什么,使这项工作。

What can I do to make this work.

编辑: 我还没有提到,我使用code点火器,所以我已经通过更换code点火器默认会话实现原生1解决了这个问题。 code点火器默认会话实现使用cookie来存储所有数据。

I haven't mention that i was using Code Igniter so i have solved this problem by replacing Code Igniter default session implementation with native one. Code igniter default session implementation uses cookie to store all data.

推荐答案

昨天我有类似的问题,找到了解决办法。我希望这将帮助别人也。

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

问题:假设有一个网站 www.somewebsite.com 并IFRAME里面whcih从我的服务器加载php文件, www.myserver.com/welcome .PHP 。网站被成功加载,以及我的欢迎页面,它表明类似你好鲍勃,所以它成功地找到用户,并记录他进来。

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.

后来我的JavaScript是做AJAX调用另一个PHP文件,并且反应是一种在未授权状态,因此会议的数据完全丢失。后刷新页面,一切工作正常。而这是发生仅在IE8!

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!

我认为,问题出在发送会话cookie到服务器,但是当我安装提琴手,我发现,IE8是正确发送的cookie,以及PHPSESSID,但是服务器是一种无法检测到正确的会话对象。另一个奇怪的是,第二次服务器发送下列头:

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德维戴氏PSA PSD IVAi IVDI CONI他对我们IND CNT

但第一次没有。在PHP脚本中手动添加这个头之后,一切工作就像一个魅力!

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

然后,当我用Google搜索了P3P胡言乱语,我发现以下网站:

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

<一个href="http://adamyoung.net/IE-Blocking-iFrame-Cookies">http://adamyoung.net/IE-Blocking-iFrame-Cookies

结论:请确保您发送的报头的每个页面设置一个cookie的

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

这是不是 IE8 + PHP 的组合,同样的问题的情况下的 IE8 + ASP.NET IE8 + JSP 等。

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

这篇关于IE8不及格的ajax请求的会话cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆