Unable to load the requested class Session in Code

2019-08-25 01:29发布

问题:

My libraries in autoload.php is:

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

I get this error:

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

I'm using codeigniter version 3.0.

回答1:

Thanks to all,

finally i found a solution,

I loaded this library like this:

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

I used it because in codeigniter 3.0 the libraries files of session is located in the path :

System/libraries/Session/Session.php.

Now, it is working...



回答2:

Check encryption key in config/config.php. If not set then set encryption key in config/config.php



回答3:

You must set encryption key in config/config.php before you use session class. As official documentation described, please make sure about that when you choose encryption key,

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.

Hope it will be useful for you.



回答4:

If you are on Unix/Linux, make sure to load your library with capital letters:

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

Also setting encryption key is important.



回答5:

Set encryption key in config.php

$config['encryption_key'] = 'your_key';

Key can be anything Hope your problem can be resolved Thnaks



回答6:

I downloaded the latest version of CodeIgniter and only replaced the Session folder from system/libraries with my old folder and it worked without changing any other things.



回答7:

Downloaded codeignitor latest version

Copied the folder Session from system/libraries/

and have replaced the folder in my current project and voila it started working for me.