English 中文(简体)
PHP会话因jquery ajax而丢失?
原标题:PHP session lost through jquery ajax?

我们的客户目前遇到麻烦。 我们的系统在登录后使用 AJAX 请求与服务器进行所有通信。 无论在哪里使用$_SESSION, 会话_ start (); 都在脚本的顶端 - 它包含在 try... capt 中, 因为一个自定义的错误处理器对错误进行例外处理 。 因此, 假代码看起来是这样 :

//set_error_handler_here
try{
session_start();
//do_something_with $_SESSION
(...)
} catch($e){
//handle error
}

现在,问题:我们的客户似乎随机失去会话, 这意味着f. $_ SESSION[ id] 将会扔出一个“ 未知索引” 错误。 互联网探索者和铬就是这种情况。 我们已经在各种系统中测试了这个系统好几个月, 并且可以确认我们以前没有犯过这个错误。

我们不使用二氧化硫,在届会结束前还有活动,有人知道解决办法是什么吗?

< strong> 编辑 : 我最终进行了测试, 看是否设置了 $_ COOKIE[ PHPSESID] 。 isset ($_ COOKIE[ PHPSESID] ) 返回假 。 这意味着客户可能受到某种形式的恶意软件的困扰, 因为它在两个浏览器上都有发生。 我想感谢所有尝试和帮助的人, 某些选项是我们没有想到的 。

最佳回答

Case 1
Are you validating the http user agent?

如果这是个问题的话, 因为 IE 在以兼容模式和正常模式运行时, 将会使用不同的用户代理 。

<强 > 病例2

您是否拥有集成应用程序服务器? 因此, 会话文件可能存放在一个服务器中, 下次请求会转到另一个服务器?

<强 > 病例3

可能是应用程序关卡错误, 因为会话根据条件或用户或其它东西不设置

case 4
If you have an iframe, It s also possible that because you re setting the cookies in an iframe, that the browsers may view it as a third-party cookie and reject it unless explicitly set out in the browser preferences to

如果那样的话,您需要一个 P3P 页头, 从您试图设置 cookie 的页面上放一个 P3P 页头 。

我建议你设置一些假饼干, 看看它是否回来了。 也设置会话饼干为< a href=> http:// en.wikipedia. org/wiki/ HTTP_ cookie# HttpOnly_ cookie" rel = “ no follow” >httpcookie , 以便无法从 Javascript (假设有些脚本的曲奇) 获取它 。

问题回答

这可能是个罕见的情况 但如果有人犯同样的错误 我也会为他带来好处

我也有同样的问题, php会话也丢失了。 我不使用jquery ajax, 而是使用简单的 xmlhttp ajax, 但我认为这并不重要,

我在停止使用ip地址处理我的ajax请求后就解决了这个问题,所以从这个角度讲: < code> http://1.2.3.4/index.php? somekey=somevalue 我读到这个: http://www.example.com/index.php? somekey=somevalue





相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签