I just don't get why my cookie return a NULL value. I think I have set the proper syntax in setting a cookie, I have no problem in the if condition I already checked it. Is the global_xss_filtering option in the config file relevant? must it be set to true in order for the cookies to work
I am glad if someone would point out my mistake.
My controller
public function store_cookie(){
if($this->input->post('remember_me') == 'remember'){
$cookie = array(
'name' => 'remember',
'value' => 'logged_in',
'expire' => '86500',
'secure' => TRUE
);
$this->input->set_cookie($cookie);
var_dump($this->input->cookie($cookie));
//This is where i do my checking and it returns NULL
die();
//model
$this->load->model('admin_model');
$this->admin_model->store_cookie($this->input->post('email'),$this->input->post('remember_me'));
}
}
public function validate_credentials2(){
$this->load->model('admin_model');
$query = $this->admin_model->validate();
if($query){
// if($this->input->post('remember_me')== 'remember'){
// $cookie = array(
// 'name' => 'remember',
// 'value' => 'logged_in',
// 'expire' => '86500',
// 'secure' => TRUE
// );
// $this->input->set_cookie($cookie);
// }
$this->store_cookie();
$data = array(
'email' => $this->input->post('email'),
'is_logged_in' => TRUE,
'role' => 'admin'
);
$this->session->set_userdata('counter2', 0);
$this->session->set_userdata($data);
redirect('admin/home', 'refresh');
}
//admin controller
public function home(){
var_dump($this->input->cookie('remember')); //still returns NULL
die();
$this->load->view('ui/admin_home');
}