Search code examples
cookiescodeigniter-2setcookie

Codeigniter 2.1 $this->input->set_cookie($some_var); NOT WORKING


I started creating a custom library that i would load for checking if user is logged in and also for registering users. Registration not started yet, but that's not important...

here's the problematic part.. it WON't set cookies:

$this->load->helper('cookie');
$some_value= 'asd';
$some_cookie_array = array(
                          'name'   => 'some_name',
                          'value'  => $some_value,
                          'expire' => 86500,
                          'secure' => TRUE
                          );
$this->input->set_cookie($some_cookie_array);

here is the full code for now: codepad.org/FILlq2qR

This is how i call the library and check if user is logged in:

$this->load->library('user_management');
$login_data = $this->user_management->login();
var_dump($login_data);

Any help is more than welcome!

Cheers!


Solution

  • Someone on the CodeIgniter Forum helped. The reason was that I was using 'secure' => TRUE which is only for https.