[eluser]Unknown[/eluser]
Hi All,
I am trying to implement the "Remember me" feature for login but I cannot set the cookie to store information.
Here is sample of my code:
Code:
function login(){
$emailid = trim($this->input->post('log_email', TRUE));//Email entered by user
$password = trim($this->input->post('log_pass', TRUE));//Password entered by user
$rem_me_flag=$this->input->post('rem_me');//Remember me checkbox value
$this->load->model('Login_model');
//Get user information in array user)info
$user_info=$this->Login_model->check_login($emailid, $password);
$username=$user_info['name'];
$user_id=$user_info['encrypted_uid'];
if($username!=""){//login details are right
//set session
$this->session->set_userdata('loggedin_user_name', $username);
//if remember me is checked
if($rem_me_flag==true){
//Set cookie
$cookie = array(
'name' => 'bu_user_id',
'value' => $user_id,
'domain' => '.localhost',
'expire' => '1209600',
'path' => '/',
'secure' => TRUE
);
$this->input->set_cookie($cookie);
}
//return ok
echo "ok";
}else{
echo "error";
}
}
I thought maybe .localhost is the problem. So, I removed the 'domain' parameter but still no success. What can be the issue?
Thanks.