Why am I experiencing session errors?
Symptoms
- Randomly being logged out of your PHP application.
- Sessions are not saving when transitioning from HTTP to HTTPS protocols. If a PHP session needs to begin in HTTP and switch to HTTPS, there will be some issues where the session is not maintained across that transition.
- General problems with sessions not seeming to be carried across web requests.
-
Sessions in general behave inconsistently. Your script has a dependency on writing data to the
/tmpdirectory.
Requirements
If you are not yet using a custom php.ini file on your server, you may follow this article on the process before proceeding with the steps in this article.
READ ME FIRST
Although this workaround is intended for a few issues we've noticed in regards to specific cases, this will most likely fix a large majority of cases where you're having problems with sessions working properly. If your symptoms quite fall into the description above, we suggest you try this workaround as your first troubleshooting step.
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.
Solution
This can be fixed by configuring a directive inside of a custom php.ini file to explicitly direct session files to save in a local directory on your (gs) Grid-Service instead of the default global /tmp folder.
This directive must be placed inside of your php.ini file on the very last line of the file:
Filename: php.ini
session.save_path = /home/00000/data/tmp
Replace 00000 with your actual site number.
After saving these changes, make sure to navigate to your data directory and create a folder called tmp. The next session created will start behaving properly and the problem should no longer occur.