【问题标题】:codeigniter session loading error: No such file or directorycodeigniter 会话加载错误:没有这样的文件或目录
【发布时间】:2017-02-17 05:08:42
【问题描述】:

我正在关注这个tutorial

但是当我访问

http://localhost/index.php/user_authentication/

我收到此警告,无法运行代码:

Warning: include(C:\xampp\htdocs\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\system\core\Exceptions.php on line 269

Warning: include(): Failed opening 'C:\xampp\htdocs\application\views\errors\html\error_php.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\system\core\Exceptions.php on line 269

Warning: include(C:\xampp\htdocs\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\system\core\Exceptions.php on line 269

Warning: include(): Failed opening 'C:\xampp\htdocs\application\views\errors\html\error_php.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\system\core\Exceptions.php on line 269

当我删除 $this->load->library('session');

警告消失了,所以我很确定我在加载会话库时遇到了错误。

我已阅读该问题已通过更改 $config['sess_save_path'] = sys_get_temp_dir(); 得到解决

但我仍然收到警告。

我什至尝试将此代码添加到我的控制器中: mkdir("/thisisthedirectory", 0700);

然后更改了我的 $config['sess_save_path'] = "/thisisthedirectory";但它不起作用

也不 $config['sess_save_path'] = "C:\thisisthedirectory";

谁能告诉我如何解决这个问题?

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

    确保您已将会话保存路径设置为类似

    $config['sess_save_path'] = APPPATH . 'cache/';
    

    文件夹权限 0700

    配置.php

    $config['sess_driver'] = 'files';
    $config['sess_cookie_name'] = 'ci_session';
    $config['sess_expiration'] = 7200;
    $config['sess_save_path'] = APPPATH . 'cache/';
    $config['sess_match_ip'] = TRUE;
    $config['sess_time_to_update'] = 300;
    $config['sess_regenerate_destroy'] = TRUE;
    

    注意:确保您已遵循 File NamingClass Naming 的 Codeigniter 样式指南

    【讨论】:

    • 感谢您的回答。我已经发出 mkdir("/thisisthedirectory", 0700);然后更改 $config['sess_save_path'] = "/thisisthedirectory";但是我仍然收到警告并且代码不会成功运行。我也尝试使用 $config['sess_save_path'] = "C:\thisisthedirectory";但它也行不通
    【解决方案2】:

    当您使用 .env 文件时,您的 sessionSavePath 不是绝对的,它会显示这样的错误

    将您的 sessionSavePath 设置为绝对路径,如下所示

    app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'
    app.sessionCookieName = 'ci_session'
    app.sessionSavePath = '/home/user/public_html/project/public/NULL'
    app.sessionMatchIP = false
    app.sessionTimeToUpdate = 300
    app.sessionRegenerateDestroy = false
    

    它会解决你的问题

    谢谢

    【解决方案3】:

    你可以尝试像这样加载父构造函数

    parent::__construct();
    $this->load->library('session');
    

    希望能解决问题

    【讨论】:

      猜你喜欢
      • 2013-08-26
      • 2021-03-10
      • 2021-10-31
      • 1970-01-01
      • 2013-08-08
      • 2013-11-04
      • 2012-02-18
      • 2012-10-21
      • 2011-03-22
      相关资源
      最近更新 更多