首页 > 解决方案 > 会话设置但不允许访问管理页面

问题描述

我真的很陌生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);

标签: phpajaxcodeignitervue.jsaxios

解决方案


推荐阅读