Why does session_start cause a timeout when one script calls another script using curl
I don't totally understand why this happens, but I got it solved.
This bug describes the same problem I'm having. I have a scripts posting to another script, both using the same session, which apparently stalls PHP.
So, before I do the whole curl post script, I call the
session_commit function, so ending the calling scripts session, and enabling the called script to restart the session.
I have two PHP scripts, both using the same session by calling
When the first script calls the second script using curl, the second script hangs when
session_start() is called.
Why would this happend?
How to kill a PHP session?
Maybe you can give a timeout to the socket? e.g.
socket_select has a timeout parameter.
The value of
1000s as timeout may be too high, because apache may have killed the process before (see
PHP session_start serializes and blocks all others sharing the same session
... And many ;)
The reason why it blocks is because the session file is being read and it might be modified at any point of time when the first script is running, hence the lock.
The remedy to this could be a
session_write_close()as pointed by this post