When we look at the Failed to write session data prompt, we will know that the session cannot be written. The solution is to set a save_path path in php. ini.
Error Message
Message: Warning: Failed to write session data (files ).
Please verify that the current setting
Session. save_path is correct () in Unknown on line 0
Solution
The Code is as follows: |
Copy code |
Session. save_path = "D:/phprun/tmp" |
This error is caused by a custom folder pointing to an error. The system does not display the error by default, prompting that the directory may not have the write permission, so you can grant the permission.
Due to the working mechanism of PHP, it does not have a daemon thread to regularly scan Session information and determine whether it is invalid. When a valid request occurs, PHP will use the global variable session. gc_probability and session. gc_divisor value to determine whether to enable a GC. By default, session. gc_probability = 1, session. gc_divisor = 100 that is to say, there is a 1% possibility to start GC (that is to say, only one gc in the 100 requests will start with one of the 100 requests ).
The function of the PHP garbage collection mechanism is to scan all Session information and subtract the last modification time of the session from the current time. the gc_maxlifetime parameter is compared. If the survival time exceeds gc_maxlifetime (24 minutes by default), the session is deleted.
However, if your Web server has multiple sites and multiple sites, the GC processing session may have unexpected results, because: When GC is working, sessions of different sites are not distinguished.