As I mentioned in my previous post, I recently upgraded my PHP installation to PHP 5, and the process caused me a lot of grief. I’m trying to document my experiences here so that in the future other people will hopefully be saved the pain that I went through.
Once I had my PHP scripts running, I quickly noticed was that every time I stored a value into the session object, that value would be gone by the time the next next request to the script came through.
I did a lot of tests to eliminate any possibility that there was nothing else in the system which might be clearing the session variables or overwriting them etc. Eventually I tracked it down to the fact the php.ini file contained a path where session data would be stored, and similar to the previous issue I had with PHP, it was again DOS style file paths which were causing the problem.
One you have identified the problem, the fix is fairly easy.
- Open up your php.ini file and find the session.save_path variable. (This variable was on line 594 of my PHP 5.2.1 php.ini file)
- Change this path to be the full path to the folder where you want the session data to be stored (not the truncated DOS path).
- Make sure that the folder you specified exists in your file system because PHP can’t create it.
- Restart your web site under IIS to make sure the new values are loaded.
While You’re at It
While you have your php.ini file open, you may as well also fix the temporary upload directory entry as well. The variable you are looking for is upload_tmp_dir, and in my php.ini file this is on the line above the session.save_path variable.
Like session.save_path, this variable needs to be the full path to the directory where PHP should temporarily store uploaded files, and the directory needs to exist on the file system because PHP cannot create it.