[eluser]Unknown[/eluser]
The cookies are stored in the database table correctly but I am getting an error when I close the browser and I try to get the private area with the reminder checkd.
error: "Unable to locate the model you have specified: user".
Any help would be appreciated. Thanks!
This is the controller:
Code:
function index()
{
if($this->session->userdata('logged_in') || $this->check_cookie_login())
{ redirect('client_private_area', 'refresh');}
//This method will have the credentials validation
$this->load->library('form_validation');
$this->form_validation->set_rules('email_address', 'Email', 'trim|required|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_check_database');
$netid = $this->input->post('netid');
if($this->form_validation->run() == FALSE)
{
$data['error'] = 'Invalid email address and/or password.';
$this->load->view('templates/header');
$this->load->view('pages/login/client_login', $data);
$this->load->view('templates/footer');
}
elseif($this->form_validation->run() != FALSE && $netid)
{
$this->rememberme->setCookie($netid);
$this->check_remindme();
redirect('client_private_area', 'refresh');
}
else
{
//Go to private area
redirect('client_private_area', 'refresh');
}
}
function check_database($password)
{
$email = $this->input->post('email_address');
$result = $this->registerclient_model->login($email, $password);
if($result){
$sess_array = array();
foreach($result as $row)
{
$sess_array = array(
'id' => $row->id,
'first_name' => $row->first_name,
'email_address' => $row->email_address
);
$this->session->set_userdata('logged_in', $sess_array);
}
return TRUE;
}
else
{
$this->form_validation->set_message('check_database', 'Invalid email address and/or password.');
return false;
}
}
public function check_remindme(){
$cookie_user = $this->rememberme->verifyCookie();
if ($cookie_user) {
// find user id of cookie_user stored in application database
$user = User::findUser($cookie_user);
// set session if necessary
if (!$this->session->userdata('user_id')) {
$this->session->set_userdata('user_id', $user);
}
$this->user = $user;
}
else if ($this->session->userdata('user_id')) {
$this->user = $this->session->userdata('user_id');
}
}
function check_cookie_login() {
if ($this->rememberme->verifyCookie()) {
// for users that have logged in with the "remember" checkbox checked
return $this->rememberme->verifyCookie();
} else if ($this->session->userdata('user_id')) {
// for users that did not login with the "remember" checkbox checked
return $this->session->userdata('user_id');
} else return FALSE;
}
[/size][/size]