Codeigniter Session Is Not Working on PHP 7

codeigniter session not working properly

Some changes needs to be done in config file.

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

This issue is likely to be faced post CI migration.
Make sure model name is declared correctly like

class Name extends CI_Model { }

First letter must be upper case in CI 3. save file in same name.

Another reason is sess_save_path. give correct path that should resolve this error

Why call session not working? (codeigniter 3)

What the answer from @Ali suggests will work or load the session library in the constructor of Dashboard.php like so...

class Dashboard extends CI_Controller
public function __construct()

//the rest of controller's code

Or if you only need sessions in one particular function inside the controller load the library in that function instead.

The point is that the library has to be loaded somewhere before you can make calls to its functions.

The choice of autoloading or explicitly loading session in a controller might depend on how often your site needs to use sessions. If every controller uses them then chose autoload. If sessions are needed in only a few places then it is a waste of resources to load them where they are not used.

php - Session are lost after redirect in CodeIgniter 3

i just solved my problem turns out i have old version of codeigniter 3 i upgrade my CI to the latest version available on the website . thank you all for the help

Codeigniter 3 Session not working With PHP 7.1.4

I found that the issue is with some earlier version of Codeigniter 3 and this is a bug already reported in their website.The underlying session bug has been fixed on:

  • 3.1.2
  • 3.1.3
  • 3.1.4

So in the latest version of Codeigniter 3 this issue doesn't happen.


If you are already in a faulty version codeigniter consider replacing system folder with latest version's one. Version 3.1.6 at the time writing this.

Codeigniter session stored in database but not working

Actually, it was a problem with Codeigniter 3.1.6 and PHP 7.1.7. I've just upgraded CI to newest version.

Codeigniter session not saved on production server

Today i had the same problem again, after the upload, my session stopped working.

After looking again at why my session didn't work, i noticed that i forgot to set the $config['cookie_domain'] in to my online version. So after changed the url into the server version, my problem got solved.

Related Topics

Leave a reply