为什么我第一次加载网站时会出现此错误?

时间:2018-05-22 06:18:18

标签: php codeigniter

Filename: drivers/Session_files_driver.php

Line Number: 191

Backtrace:

File: /home/im/public_html/index.php
Line: 321
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;

This is the screenshot

2 个答案:

答案 0 :(得分:0)

  

将此$autoload['libraries'] = array('database','session');更改为   配置文件夹中的自动加载配置文件

答案 1 :(得分:-1)

  

您收到此错误,因为您可能有Windows服务器。对于   我有一个解决方案只是遵循以下步骤。

1)转到system/libraries/Session/drivers/Session_files_driver.php

2)使用Session_files_driver.phpsublime打开Code Editor个文件。

3)现在找到function open($save_path, $name)功能或throw new Exception

4)现在只需removecomment其他部分方法即可。

public function open($save_path, $name)
    {
        if ( ! is_dir($save_path))
        {
            if ( ! mkdir($save_path, 0700, TRUE))
            {
                throw new Exception("Session: Configured save path '".$this->_config['save_path']."' is not a directory, doesn't exist or cannot be created.");
            }
        }
        elseif ( ! is_writable($save_path))
        {
           // This line you have to comment and save file.
           //throw new Exception("Session: Configured save path '".$this->_config['save_path']."' is not writable by the PHP process.");
        }

        $this->_config['save_path'] = $save_path;
        $this->_file_path = $this->_config['save_path'].DIRECTORY_SEPARATOR
            .$name // we'll use the session cookie name as a prefix to avoid collisions
            .($this->_config['match_ip'] ? md5($_SERVER['REMOTE_ADDR']) : '');

        return $this->_success;
    }

5)现在保存文件并通过Ctrl + Shift + R硬刷新来重新加载。

6)那就是它。你的文件将会运行。