What I'd like to do is on validating a CI user, when setting their session data, pull some data from a field set in the db.
At the moment I have this within my controller;
function validate()
{
$query = $this->model_auth->validate();
if ($query) // if the user's credentials validated
{
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => TRUE
);
$this->session->set_userdata($data);
redirect('dashboard/');
} else {
$data['error'] = 'Invalid User Id and Password combination';
$this->load->view('view_login',$data);
}
}
and this is my model
function validate() {
$this->db->where('username', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
$query = $this->db->get('users');
if($query->num_rows == 1) { return TRUE; }
}//validate
What I'd like to do is set something like this;
$data = array(
'username' => $this->input->post('username'),
'user_level' => $ThisIsSomethingWithinTheDB,
'is_logged_in' => TRUE
);
Within my controller, with $ThisIsSomethingWithinTheDB relating to the relevant entry within the db under the user_level column.
I'm currently still very much learning as I go so any help would be very much appreciated.