I found a problem when I was doing something recently.
When an interface crashes and the access address is tested, the browser remains in the waiting status.
You can only restart the web server.
If you do not restart the web server for code debugging, you will not be able to continue when session_start () is found.
The cause of the problem was finally understood:
Because the request sent by the browser is processed by creating a thread on the web server, the session is stored on the server.
The browser is waiting for a response, indicating that the web server is processing your request. However, due to the long response timeout, you may have performed the next debugging.
Before the previous request is killed, it occupies your session resources, and the session resources cannot be shared. The requests you send again will always be waiting for the session resources to be obtained.
That is to say, you can get the session resources and parse the code until the last request ends.
Previously, it was found that the PHP page was slow to call the session_start () method, and even took dozens of seconds. Now I finally found the cause.
Solution
Because the session uses files, multiple requests will lock the Session file and try to release the Session as soon as possible when no Session is needed.
UseSession_write_close () method
For example
The code is as follows: |
|
Session_start (); // starts the session $ _ SESSION ['user'] = "Me "; Session_write_close (); // close write capability Echo $ _ SESSION ['user']; // you can still access it |