If you do not restart the web server for code debugging, you will not be able to continue until session_start (). The cause of the problem is finally understood: because the request sent by the browser is still processed by a thread established on the web server, because the session is
Recently, when I was doing something, I found a problem. When an interface crashes and the access address is tested, the browser is always waiting for a response, only restart the web server.
If you do not restart the web server for code debugging, you will not be able to continue until session_start (). The cause of the problem is finally understood: because the requests sent by the browser are processed by creating threads 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 normally and enter the code parsing only when the last request ends. it was found that the PHP page was very slow to call the session_start () method, and even took dozens of seconds, the cause is finally found.
Solution: because the session uses a file, multiple requests will lock the Session file. try to release the Session as soon as possible when no Session is needed. use the session_write_close () method, for example:
- Session_start (); // starts the session
- $ _ SESSION ['user'] = "Me ";
- Session_write_close (); // close write capability
- Echo $ _ SESSION ['user']; // you can still access it