将Codeigniter 3应用于新的域主机会为session_files_drive.php提供mkdir()错误

时间:2019-02-05 21:48:36

标签: codeigniter codeigniter-3

我有一个Codeigniter框架设置,我将其跨多个域设置作为默认起点。它给了我下面的错误。添加干净安装的CI3并添加数据库信息,并在自动加载后执行以下操作是相同的:

$autoload['libraries'] = array('database', 'session', 'user_agent', 'upload');
$autoload['helper'] = array('form', 'url');

我尝试删除'session',库,但错误消失了。

在下面您看到错误:

A PHP Error was encountered
Severity: Warning

Message: mkdir(): Invalid path

Filename: drivers/Session_files_driver.php

Line Number: 136

Backtrace:

File: /customers/9/0/3/***.***/httpd.www/index.php
Line: 315
Function: require_once

A PHP Error was encountered
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /customers/9/0/3/***.***/httpd.www/system/core/Exceptions.php:271)

Filename: core/Common.php

Line Number: 564

Backtrace:

An uncaught Exception was encountered
Type: Exception

Message: Session: Configured save path '' is not a directory, doesn't exist or cannot be created.

Filename: /customers/9/0/3/***.***/httpd.www/system/libraries/Session/drivers/Session_files_driver.php

Line Number: 138

Backtrace:

File: /customers/9/0/3/***.***/httpd.www/index.php
Line: 315
Function: require_once

我已经隐藏了域名。对此感到抱歉,但是我认为那不是至关重要的。

这是我的会话配置:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

1 个答案:

答案 0 :(得分:1)

如果使用Codeigniter的/ default)文件会话存储驱动程序,则需要记住,它仅支持$config['sess_save_path']的绝对路径

config.php状态:

|   The location to save sessions to, driver dependent.
|
|   For the 'files' driver, it's a path to a writable directory.
|   WARNING: Only absolute paths are supported!
|
|   For the 'database' driver, it's a table name.
|   Please read up the manual for the format with other session drivers.
|
|   IMPORTANT: You are REQUIRED to set a valid save path!

根据您的环境使用这些:

mkdir /<path to your application directory>/sessions/

chmod 0700 /<path to your application directory>/sessions/

chown www-data /<path to your application directory>/sessions/

$config['sess_save_path'] = sys_get_temp_dir(); 
//php function which returns the directory path used for temporary files

有关CI-sessions files driver的更多信息

P.S。看看Session_files_driver.php(在您的system / session / driver目录中)。在第136行中,您可以看到他们对mkdir的使用:if ( ! mkdir($save_path, 0700, TRUE))=>>through error if dir is not writable)