Codeigniter 3 session not working

On a web application, session not working. I verified PHP session is working with script

When refreshing the script, the number start increasing, that confirms PHP session works fine on the server.

As for Codeigniter, we need to check the session settings in file application/config/config.php

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = FCPATH.'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

That looks good. Session will be saved in folder


FCPATH will be replaced with web application root folder where index.php is present. I verified ci_session folder exists and changed its permisison to 777, but that did not fixed the session problem.

To verify session is working, i added 2 function to controller

public function set-session()
    $newdata = array(
        'username'  => 'johndoe',
        'email'     => '[email protected]',
        'logged_in' => TRUE

public function read-session()
    $name = $this->session->userdata();
    echo "

I can call these functions to verify is session is setting properly with url like yourdomain/controller-name/function-name

The problem was due to PHP 7. To fix it, edit file



ini_set('', $params['cookie_name']);

Replace with

ini_set('', $params['cookie_name']);

You can find more about Codeigniter session at

Need help with Linux Server or WordPress? We can help!

One thought on “Codeigniter 3 session not working

Leave a Reply

Your email address will not be published. Required fields are marked *