[eluser]patbert[/eluser]
Ok, I have been hacking away at this. . .
I really wanted to have the user id number in the session data, so in auth_model.php I created:
Code:
function get_id ($table, $email)
{
$this->db->select($table. '.id');
$this->db->from($table);
$this->db->where($table. '.email', $email);
$i = $this->db->get();
if ( $i->num_rows() > 0 )
{
$row = $i->row();
return $row->id;
}
return false;
}
I have no idea if there is a better way to do that, but it works. Then in the library I added a few lines to the login function:
Code:
// If they match then login.
if ( $password === $dbpassword )
{
$id = $this->ci->auth_model->get_id($this->usertable, $email);
$data = array(
'email' => $email,
'id' => $id,
'logged_in' => 'yes'
);
$this->ci->session->set_userdata($data);
return true;
}
Then you can grab the userid with $this->session->userdata('id')
One thing I cannot get to work is the logout function.
In my controller I have:
Code:
function logout() {
$this->auth->logout();
$this->session->set_flashdata('response', 'Have a nice day');
redirect('blog');
}
It runs happily enough, but the session is still there after the redirect. Maybe this is an issue on my end?