Why should session_write_close be used in long polling?

烂漫一生 提交于 2019-11-30 07:30:53
zaf

This is my understanding:

When file based sessions are used each request literally locks the file until the end of the request.

Meaning that the next request (that also uses the session data) has to wait for the lock to be released.

This is used to avoid session data corruption.

Using session_write_close() will clean up (but not lose any session data) and release the lock earlier on the file allowing other requests to continue.

This is good practice especially if you have scripts that sleep a lot, probably.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!