PHP hints failed to write session data error resolution _php tips

Source: Internet
Author: User

This paper analyzes the solution of PHP prompt failed to write session data error in detail. Share to everyone for your reference. The specific methods are as follows:

First, the question:

Prompt message:warning:failed to write session data (files). Please verify that this current setting of Session.save_path is correct () in Unknown on line 0

Second, the solution:

The code is as follows:

Copy Code code as follows:
Session.save_path = "D:/phprun/tmp"

This is the custom folder pointing to errors, the system does not appear by default, prompting sometimes may be the directory does not write permission, so everyone to the permissions on it.

Because of the working mechanism of PHP, it does not have a daemon thread that periodically scans session information and determines whether it is invalidated, and when a valid request occurs, PHP will session.gc_probability and session.gc_ according to the global variables Divisor value to determine whether to enable a GC, by default, Session.gc_probability=1, Session.gc_divisor = 100, which means 1% probability to start GC ( This means that only one GC in 100 requests will be started with one of 100 requests.

The job of the PHP garbage collection mechanism is to scan all session information, subtract the time of the session last modified with the current time, and compare it with the Session.gc_maxlifetime parameter if the lifetime exceeds Gc_maxlifetime (default 24 minutes ), the session is deleted.

However, if your Web server has multiple sites, multiple sites, GC processing session may have unexpected results, because the GC at work, does not distinguish between different site sessions.

I hope this article will help you with your PHP program design.

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.