Hasan Setiawan

Write, write, write give your wings on code!

Follow me on GitHub

CodeIgniter setting session path

In your save path you need to set up a location folder. Use 'files' as session driver preferred. As like below I have set up a cache to store sessions in BASE PATH which is setting folder. Make sure you have auto loaded sessions and $config['encryption_key'] = '' add key.

You can set up a database sessions but this works just as well. Make sure folder permissions 0700

      
          // application/config/config.php
          $config['sess_driver'] = 'files';
          $config['sess_cookie_name'] = 'ci_session';
          $config['sess_expiration'] = 1440;
          $config['sess_save_path'] = BASEPATH . 'yourfoldername/cache/';
          $config['sess_match_ip'] = TRUE;
          $config['sess_time_to_update'] = 300;
      
  
Once that is done then you should be able to do something like.

      
           $this->load->library('session');
           $data_session_set = array('logged' => 1, 'username' => $this->input->post('username'), 'user_id' => $this->user_auth->get_id());
           $this->session->set_userdata($data_session_set);