Recently encountered a problem, the migration code to the Linux system, re-build the PHP environment, run the code,
In the login page, can not access the background, will return to the login page, the code test, no error reported,
Finally check to be jump, the session lost problem, how to lose it? With this problem, I looked up a lot of information,
This is found to be the cause of these kinds of:
1.session storage Path (directory) does not exist, nature can not generate session temporary file
2.session Storage Path There is no permission, if not, it is impossible to store session data
3. The session data can be stored normally, but it will be emptied after the session is deposited.
Solution:
First, create the phpinfo.php file in the project root directory, write Phpinfo () in the file, run the file, view the page,
You can find the storage path for the session,
Second, enter Linux to find the session storage path exists, does not exist to create the storage directory, and assign permissions,
If there is a session store path, you can see if it has permissions, no permissions are assigned,
Finally, whether it is a third reason, you can find the Date.timezone is not set in the Phpinfo.php page,
Then locate Date.timezone in the php.ini configuration file to configure
The first thing I see in my project is that I create the storage directory and assign permissions, and the problem is solved.
I hope this blog is helpful to everyone.
Finally, remind you, do not find the session in the configuration file storage path, the above method to find the session storage path is accurate,
I spent a lot of time to solve the problem is that the configuration file in the session storage path and the method found in the session storage path is different,
That's why the problem has not been solved.
Why the session was lost under Linux