我的主要项目是在核心php中创建的,我正在处理一个模块,该模块位于同一项目文件夹中的codeigniter中。
$_SESSION['UserName'] = $loginDetailAr['UserName'];
$_SESSION['UserType'] = $loginDetailAr['UserType'];
$_SESSION['UserTypeName'] = $loginDetailAr['UserTypeName'];
$_SESSION['IsAdmin'] = $loginDetailAr['IsAdmin'];
答案 0 :(得分:0)
加载会话库
$this->load->library('session');
// can access variables with this->session
$is_admin = $this->session->IsAdmin;
有关详细信息,请参阅。 https://www.codeigniter.com/user_guide/libraries/sessions.html
答案 1 :(得分:0)
这可以帮到你
$this->load->library('session');
$ result = $ this-> login_model-> userLogin($ email,$ password);
if ($result) {
$sess_array = array();
foreach ($result as $loginDetailAr) {
$sess_array = array(
'UserName' => $loginDetailAr->UserName,
'UserType' => $loginDetailAr->UserType,
'UserTypeName' => $loginDetailAr->UserTypeName,
'IsAdmin' => $loginDetailAr->IsAdmin,
);
$this->session->set_userdata('logged_in', $sess_array);
}
return TRUE;
} else {
$this->form_validation->set_message('check_database', ' Invalid Email Or Password ');
return FALSE;
}