Php prompts Failed to write session data error

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.