异步请求时候会造成session 死锁现象
和同事探讨了下 可使用 session_write_close() 解决此问题
复制代码 代码如下:
Description
void session_write_close ( void )
End the current session and store session data.
Session data is usually stored after your script terminated without the need to call session_write_close(), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.
功能: 结束当前的session 操作 保存session 数据
说的很明白了, 当脚本请求没有调用session_write_close(); 时虽然 session 的数据是存储住了。但是 session Date(也就是session 文件) 是锁住状态
是为了避免 其他应用此时操作session 造成不必要后果 当使用框架时 不同文件可能会不停地操作session 为了不造成其他操作对当前session 的死锁等待
下一篇:如何使用PHP可变函数