PHP Custom Session Save Directory _php tutorial

Source: Internet
Author: User
Tags php session
PHP Custom Session Save Directory

Today a customer site suddenly reported a bunch of error hints, the code is as follows:

Warning:session_start () [Function.session-start]: Open (/VAR/LIB/PHP/SESSION/SESS_0DJ5OL1FP235A0SCU79S8C33T1, O_ RDWR) Failed:permission denied () in/home/wethost/wwwroot/include/seccode.inc.php on line 7

Warning:Unknown:open (/VAR/LIB/PHP/SESSION/SESS_0DJ5OL1FP235A0SCU79S8C33T1, O_RDWR) Failed:permission denied (in) Unknown on line 0

Warning:Unknown:Failed to write session data (files). Please verify this current setting of Session.save_path is correct (/var/lib/php/session) in Unknown on line 0

The general meaning of the above hint is that there is no permission to read the files in the Session directory. Presumably the virtual host provider configuration server has made some modifications. In order to avoid trouble, this time directly in PHP set the session file to save the directory.

Add the following code to the PHP code in front of Session_Start ().

Ini_set (' Session.save_path ', DirName (__file__). ' /phpernote/');

Or:

Session_save_path (DirName (__file__). ' /phpernote/');

The previous session file generated by the website is saved to the Phpernote directory of the current root directory of the Web site.

Note that not all configuration parameters can be set in the script, which is related to the scope of the parameter.

The following is a description of the configuration parameter scope that references PHP

Php_ini_perdir: Directives can be modified in php.ini, httpd.conf, or. htaccess files;

Php_ini_system: Directives can be modified in php.ini and httpd.conf;

Php_ini_user: The instruction can be modified in the user script;

Php_ini_all: The instruction can be changed anywhere;

So only the parameters of the Php_ini_user and Php_ini_all scopes can be set in the script to take effect. The specific scope of the parameter can be retrieved from the network.

Articles you may be interested in

    • PHP set the session life cycle
    • PHP fatal error allowed memory size of ... How memory-deficient errors should be resolved
    • PHP Empty (delete) the file under the specified directory, do not delete the Directory folder method
    • PHP calculates the number of days (day) of a two-date function
    • The difference between a PHP session and a cookie
    • PhpMyAdmin cannot start session without errors error resolution
    • PHP gets the timestamp of the start time and end time of the week of the specified date
    • PHP Performance Optimizations: Use Isset () to determine string length faster than strlen ()

http://www.bkjia.com/PHPjc/827567.html www.bkjia.com true http://www.bkjia.com/PHPjc/827567.html techarticle PHP Custom Session Save directory today, a customer web site suddenly reported a bunch of error prompts, the code is as follows: Warning:session_start () [Function.session-start]: Open (/var/lib/ PHP/S ...

  • Related Article

    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.