php - 会话设置但不允许访问管理页面
问题描述
我真的很陌生CodeIgniter
。我的代码有问题,我通过 Axios 创建了一个登录系统Vue
。会话已成功设置,但我仍然不允许访问管理页面,我用于Ajax
从视图发送数据,并且控制器上已成功接收数据。
登录过程已成功运行,我为此创建了一个会话,当我抛出回退返回时Vue
,会话被成功读取,但是当我将页面切换到管理页面时,会话不可读并且页面被重定向到登录页面,我的代码有什么问题?
$uname = $this->input->post('username');
$upass = $this->input->post('password');
$utype = $this->input->post('types');
$where = array('user'=>$uname, 'pass'=>md5($upass), 'type'=>$utype);
$check = $this->Login_models->login_check("user", $where)->num_rows(); //account checking
$type = $this->Login_models->check_user_identity($utype)->row_array(); //user check, admin or student
if ($check > 0) {
$this->_result['error'] = FALSE;
if($type['type'] == 'admin'){
$data_session = array('nama'=>$uname, 'status'=>"admin");
$this->session->set_userdata($data_session);
$this->_result['type'] = 'admin';
}
else if($type['type'] == 'student'){
$data_session1 = array('nama'=>$uname, 'status'=>"student");
$this->session->set_userdata($data_session1);
$this->_result['type'] = 'student';
}
}else{
$this->_result['error'] = TRUE;
$this->_result['message'] = array(
'no_account' => 'Account not found'
);
}
}
echo json_encode($this->_result);
解决方案
推荐阅读
- crash - ejabberd 不起作用,因为 erl.exe 总是崩溃
- r - 如何在 R 中读取这个特定的 .dat 文件?
- google-chrome - 如何安全地存储 Chrome 扩展程序数据?
- apache-kafka - 无法在 kafka 中列出经纪人 ID
- r - 从R中的列名中间删除部分
- python - 查找与另一个字典中的键、值对匹配的字典的 Pythonic 方法
- javascript - 当我使用 .innerText 时未定义但当我不使用时则不是
- javascript - 如何延迟加载图像?
- c# - 分块上传视频 Azure blob 存储
- tensorflow - 词向量的中心