[eluser]phused[/eluser]
Edit: Problem solved, it was something silly!
I have the following function in a model:
Code:
public function login($username, $password)
{
$this->db->select('id, pass');
$this->db->where('user', $username);
$query = $this->db->get('users');
if($query->num_rows() > 0)
{
$row = $query->row_array();
$password = $this->hash_password($password, substr($row['pass'], 0, 10));
// Compare them
if($row['pass'] == $password)
{
// Passwords match, set session data and return true.
$this->session->set_userdata('user', $username);
$this->session->set_userdata('id', $row['id']);
return true;
}
// Passwords don't match
return false;
}
// No matching username
return false;
}
For some reason, even if the user has logged in with the correct credentials, the user is redirected back to the login page. The cookie and session data have also been created because if enter the dashboard controller manually, it displays the content of that page (I have a function to check is certain data is on the cookie).
I also replaced the return statements on the Model with a string and echo'd them, for some reason all three strings were echo'd so I'm assuming the function on the model is returning true first, then false and false.