Home  >  Article  >  Backend Development  >  PHP prompts Failed to write session data error_PHP tutorial

PHP prompts Failed to write session data error_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:42:56774browse

When we look at the Failed to write session data prompt, we know that the session cannot be written. The solution is to set a save_path in php.ini.

Error message

Prompt message: Warning: Failed to write session data (files).
Please verify that the current setting of
session.save_path is correct () in Unknown on line 0


Solution

The code is as follows
 代码如下 复制代码

session.save_path = "D:/phprun/tmp"

Copy code


session.save_path = "D:/phprun/tmp"



This is caused by a custom folder pointing error. The system will not appear by default. Sometimes, the prompt may be that the directory does not have write permissions, so everyone can just give permissions.
Due to the working mechanism of PHP, it does not have a daemon thread to regularly scan Session information and determine whether it has expired. When a valid request occurs, PHP will decide whether to proceed based on the values ​​of the global variables session.gc_probability and session.gc_divisor. Enable a GC. By default, session.gc_probability=1, session.gc_divisor =100 means there is a 1% probability of starting a GC (that is, only one gc in 100 requests will be accompanied by one of the 100 Started by request).

The job of the PHP garbage collection mechanism is to scan all Session information, subtract the last modification time of the session from the current time, and compare it with the session.gc_maxlifetime parameter. If the survival time exceeds gc_maxlifetime (default 24 minutes), the session will be delete.

However, if your web server has multiple sites, unexpected results may occur when GC processes sessions. The reason is: when GC is working, it does not distinguish between sessions of different sites. http://www.bkjia.com/PHPjc/633210.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/633210.html
TechArticle
As soon as we saw the Failed to write session data prompt, we knew that the session could not be written. The solution is to set it in php.ini Just set a save_path path in it. Error message: W...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn