Using same session ID within two PHP scripts at same time

可紊 提交于 2019-12-01 09:06:39

Yes, this is called "session locking" and is normal in PHP.

One solution is not not use sessions, just set cookies for your required persistent information.

Another solution is to implement your own session handler:

http://php.net/manual/en/session.customhandler.php

A detailed walkthrough about custom MySQL session handlers is here:

http://phpmaster.com/writing-custom-session-handlers/

I also found quite simple solution for this problem. We can use session_write_close(); to unlock session file in script 1, then we can make any file_get_contents(), curl_exec() etc without any worries and after these operations turn session back by session_start(). Checked by myself, works as charm!

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