i am making this one where i want to pass the user data on my sessions as you can see on my codes
controller
public function loginValidate(){
$this->load->library('form_validation');
$this->form_validation->set_rules('USERNAME','Username','required|trim|callback_validateCreds');
$this->form_validation->set_rules('PASSWORD','Password','required|trim');
if($this->form_validation->run($this) == FALSE){
$this->index();
}else{
$data = array(
'USERNAME' => $this->input->post('USERNAME'),
'is_logged_in' => true,
--------->>'user_data' => $this->Login_Model->userinfo()
);
$this->session->set_userdata($data);
$this->dashboard();
}
}
models
public function userinfo(){
$sql = "SELECT
tbl_users.ID_NUM,
tbl_users.USERNAME,
user_group.GROUP_NAME,
user_rights.RIGHTS,
usertypes.USERTYPE,
department.DEPARTMENT
FROM tbl_users
INNER JOIN user_group
ON tbl_users.GROUP_ID = user_group.GROUP_ID
INNER JOIN user_rights
ON user_group.GROUP_ID = user_rights.GROUP_ID
INNER JOIN usertypes
ON user_rights.RIGHTS = usertypes.USERCODE
INNER JOIN department
ON usertypes.DEP_ID = department.DEP_ID
WHERE tbl_users.USERNAME = ?
AND tbl_users.PASSWORD = ? ";
$data = array(
'USERNAME' => $this->input->post('USERNAME'),
'PASSWORD' => $this->input->post('PASSWORD')
);
$query = $this->db->query($sql, $data);
return $query;
}
what i wanted to do is when i log-in to check the values inside my user_data array. for example
if (userdata array in my sessions array have the value admin){
show this}
i cannot or atleast i dont think that i can break down that array because my query output will be for example.
---------------------------------------------
username | group_name | rights |
---------------------------------------------
abc | group_1 | admin1 |
---------------------------------------------
abc | group_1 | admin2 |
---------------------------------------------
abc | group_1 | admin3 |
---------------------------------------------
how will i be able to check that array inside the sessions array if some specific value is inside that array. for example if the array has admin1 i'll do this and etc..