Matt
Matt

Reputation: 2509

Session class error that requires an encryption key in codeigniter

I'm new to codeigniter and have an okay experience with php. I recently encountered an error where codeigniter tells me

 "In order to use the Session class you are required to set an encryption key in your config file." 

And I heard the solution was to paste in

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

in the config file.

Now I have absolutely no idea what just happened here. What is this encryption key? Why is it required for session class and what's the point?

Thank you everyone.

Upvotes: 1

Views: 10381

Answers (1)

Colin Brock
Colin Brock

Reputation: 21575

From the Session class documentation:

Note: Even if you are not using encrypted sessions, you must set an encryption key in your config file which is used to aid in preventing session data manipulation.

Also, you shouldn't need to paste anything. $config['encryption_key'] already exists in config.php but is set to an empty string:

/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| If you use the Encryption class or the Session class you
| MUST set an encryption key.  See the user guide for info.
|
*/
$config['encryption_key'] = '';

Upvotes: 2

Related Questions