Home >Backend Development >PHP Tutorial >The painful experience of losing Apache + PHP SESSION under Windows
Today’s work is to migrate a PHP site to a new server.
Create a Windows Server 2008 virtual machine, and stop the net stop http service on it (to avoid competing for port 80), install and configure Apache + PHP, migrate the site to the new server, the site opens normally, and Apache + PHP runs normally , the connection to MySql Server was normal, everything was fine, I was thinking of completing the work in half an hour, but then the nightmare began.
This site uses single sign-on, and the login process includes JavaScript asynchronous operations, including SOAP calls to Web Services. After logging in, it jumped directly back to the login page without any error message. We considered the following possibilities:
1. Is the account abnormal? Tested on other systems, the account status is normal.
2. Did the JavaScript asynchronous operation fail? Use IE developer tools to track the Javascript return value, and the return value is normal.
3. Did the Web Service call fail? Use Fiddler to track the return value of the Web Service, indicating that the verification has been successful and the local login has been completed.
After repeated tracking and debugging, I began to suspect that the SESSION of the site was lost:
1. The JavaScript asynchronous operation failed to set the SESSION. Is it because the SESSION IDs of synchronous access and asynchronous access are different? This has only happened with asynchronous calls in Flash, will it also happen with JavaScript? The SESSION ID value of output synchronous access and asynchronous access is the same.
2. Create 2 PHP test pages, set SESSION in one page, but cannot read it in the other page. Check the php.ini related settings, it seems to be normal. Check the session.save_path = "C:/php/tmp" path, but there are no SESSION related files, and the setting does not even include the tmp directory.
The ending is ridiculous. Without the tmp directory, PHP cannot write the SESSION file, and naturally the SESSION is lost. Why is there no tmp directory? Because it is not included in the installation package...my 3 hours.
The above introduces the painful experience of losing Apache + PHP SESSION under Windows, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.