[eluser]Jay Turley[/eluser]
Hi all-
searched the forums but couldn't find an answer to this so I'm gonna throw it out there...
I have configured my CI sessions to use the database. While I can login and out of my application, the user_id field in the database is never updated with the user id loaded from the database.
The login code is as follows:
Code:
$conditions = array(
'username' => $this->input->post('username',TRUE),
'password' => dohash($this->input->post('password')),
);
$this->db->select('id');
$query = $this->db->getwhere('users', $conditions, 1, 0);
if ($query->num_rows != 1) {
$this->load->view('login_fail');
} else {
$row = $query->row();
$this->session->set_userdata(array('user_id'=>$row->id));
$this->load->view('login_success');
}
My config file has the following pertinent code:
Code:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
No matter what I do, the ci_sessions table always contains
user_id = 0
From my limited understanding, enabling the database for sessions should not change the working of any of the session functions.
Can anyone tell me where I have gone wrong? Let me know if you need more code...
Thanks!