Solving session problems in CodeIgniter after upgrading PHP version


If you are using CodeIgniter in your project and you are running PHP version 7.1 or Higher or thinking to upgrade it, then you may face an issue in your project. If you start checking then you will find all the features related to session stops working. Your authentication will fail if it is using session.

This issue has been arises due to upgradation of CodeIgniter’s session library in their new versions. And this library does not let save the data in session by default.


The Reason behind this issue is that PHP 7.1 has restrict the length of session to 4 bits per character and also changed its INI Settings to

To deal with this issue, CodeIgniter 3.1 comes up with the new session configuration settings . It added the configure_sid_length() function written especially for PHP version greater than 7.1


You can check all changes in Session.php using link :-

This is the changes that have been made to more strict session Id and make compatible for 7.1.


For that you have to upgrade your system directory files. Session library basically are upgraded in the CodeIgniter version 3.1.2.

They have also depreciate some function prep_for_form() method , which is/can also be used as a rule in set_rules() to automatically perform HTML encoding on input data. So, remove the use of those depreciated functions (less likely to be use) .

Before starting upgradation, just back up your changes of system directory folder if you had made any changes in your files (less chances) then Step by Step starting from your project CodeIgniter version to Current CodeIgniter version (3.1.5) , replace the files of system directory.

You can Download all the CodeIgniter version from CodeIgniter forum .
Refer Link –
You can also check their upgradtion process if any issue :
Refer Link :-

Please follow and like us:

Leave a Reply