PHP session_start() 导致 HTTP 请求挂起 [英] PHP session_start() causing HTTP requests to hang

查看:85
本文介绍了PHP session_start() 导致 HTTP 请求挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从头开始用 PHP 编写的应用程序.我正在使用 PHP 的本机会话处理程序函数来处理用户身份验证和持久性.

I have an application I've written in PHP from scratch. I'm using PHP's native session handler functions for handling user authentication and persistence.

在开发服务器上进行测试时,一切都很顺利.身份验证、持久性等工作正常.

When testing on the development server, everything is peachy. Authentication, persistence, etc, works fine.

当安装在生产服务器上时,一切正常,直到用户身份验证——当应用程序实际将数据写入会话对象时,突然之后的 HTTP 请求在 session_start() 执行时完全挂起.

When installed on the production server, everything works fine up until the user authentication -- when the app actually writes data to the session object, suddenly the HTTP request that follows it completely hangs exactly when session_start() is executed.

我怀疑临时会话文件被 PHP 锁定并且从未被释放,因此我尝试使用 session_write_close() 跟踪应用程序写入会话对象的位置,但没有好像没什么效果.

I suspected the temporary session files were being locked by PHP and never released, so I tried following up the spots where the app is writing to the session object with session_write_close(), but that didn't seem to have any effect.

这听起来像是文件锁定问题还是其他问题?我很困惑为什么 session_write_close 似乎没有处理文件锁定问题,如果是这样的话,这就是为什么我想知道这里是否还有其他东西在起作用.

Does this sound like a file lock issue or is this something else? I'm confused on why session_write_close doesn't seem to be taking care of the file lock issue if that's the case, which is why I'm wondering if there could be something else at play here.

任何可能的想法或想法?

Any possible thoughts or ideas?

回复 Pekka 的好建议:

Reply to Pekka's great suggestions:

  • 生产服务器是一个 linux 环境.phpinfo 报告 Linux wynn 2.6.18-164.9.1.el5PAE #1 SMP
  • 页面没有调用自身
  • 我可以读/写会话文件夹和文件.我可以看到通过身份验证尝试序列化到文件中的身份验证数据.

推荐答案

只是一些想法 - 除了 pygorex 的评论首先打开 error_reporting,这绝对应该排在第一位.

Just a few ideas - in addition to pygorex's comment to first turn up the error_reporting, which should definitely come first.

  • 可能不是,但在用户对 session_start 的贡献注释中描述了三个挂断:

  • Probably not it, but there are three hangups described in the User Contributed Notes to session_start:

当页面调用自身时使用相同的会话

在 Windows 上

您能否读取会话 cookie 并检查/tmp 目录中是否存在该名称的会话文件?那个文件可以写吗?是否包含数据?

Can you read your session cookie and check whether a session file of that name exists in your /tmp directory? Is that file writable? Does it contain data?

如果一切都失败了,session_save_handler() 上的手册页 看起来像是对默认会话处理函数的完全自定义替换.考虑使用这些进行详细调试.

If all else fails, the manual page on session_save_handler() has what seems like a full custom replacement for the default session handling functions. Consider using those for detailed debugging.

这篇关于PHP session_start() 导致 HTTP 请求挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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