I am having trouble reading cookies on localhost using MAMP and Codeigniter.
I am trying to display acess authentication cookie in admin area. I can set a cookie (I see this in my browser - Chrome), but I cannot read it after that to provide acess. I have already tried many configurations, but nobody is working. I really need help with this.
These are the main parts of my code:
Here I set the cookie
$cookie = array(
'name' => 'login',
'value' => 'true',
'expire' => '0',
'secure' => TRUE
);
set_cookie($cookie);
Here I redirect the user to the login page if there is no cookie and control panel if the cookie is set
function login_redirect() {
$this->load->helper('cookie');
if (uri_string() == 'admin/controlpanel') {
if ($this->input->cookie('login')) {
} else {
redirect('admin/');
}
}
if (uri_string() == 'admin') {
if ($this->input->cookie('login')) {
redirect('admin/controlpanel');
}
}
}
OBS: all this code is in admin_model
Any tips?
Thanks and sorry for my english. I hope I get it.
source
share