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 ...