无法在 Codeigniter 中加载请求的 class 会话

Unable to load the requested class Session in Codeigniter

我在 autoload.php 的图书馆是:

$autoload['libraries'] = 
     array('database','pagination','session','cart','form_validation');

我收到这个错误:

An Error Was Encountered Unable to load the requested class: session

我使用的是 codeigniter 3.0 版。

检查 config/config.php 中的加密密钥。如果未设置,则在 config/config.php

中设置加密密钥

在使用会话 class 之前,您必须在 config/config.php 中设置加密密钥。如official documentation所述,请确保在选择加密密钥时,

To take maximum advantage of the encryption algorithm, your key should be 32 characters in length (128 bits). The key should be as random a string as you can concoct, with numbers and uppercase and lowercase letters. Your key should not be a simple text string. In order to be cryptographically secure it needs to be as random as possible.

希望对你有用。

如果您在 Unix/Linux,请确保使用大写字母加载您的库:

$autoload['libraries'] = array('Session');
                                ^

设置加密密钥也很重要。

感谢大家,

我终于找到了解决办法,

我是这样加载这个库的:

$this->load->library('Session/session');

我使用它是因为在 codeigniter 3.0 中会话的库文件位于路径中:

System/libraries/Session/Session.php.

现在,它正在工作...

在 config.php

中设置加密密钥
$config['encryption_key'] = 'your_key';

键可以是任何东西 希望你的问题能得到解决 特纳克斯

我下载了最新版本的 CodeIgniter,只用我的旧文件夹替换了 system/libraries 中的 Session 文件夹,并且它在没有更改任何其他内容的情况下工作。