我试图在登录时重定向到控制器中的特定功能,它可以工作,但它加载了相同的视图。我的代码在
下Box
查看
class Authentication extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('Authentication_model');
$this->load->model('Common_model');
$this->load->library('form_validation');
}
public function index() {
if ($this->session->userdata('user_id')) {
//If the user is Super Admin
if ($this->session->userdata('role') == 'Super Admin') {
redirect("Admin/adminProfile");
}elseif ($this->session->userdata('role') == 'Admin') {
redirect("Outlet/outlets");
} else {
redirect("Authentication/userProfile");
}
}
$this->load->view('authentication/login');
}
public function test() {
die('hi');
}
现在,当我登录时,它会转到下面的链接
baseurl.com/Authentication/test
并加载相同的登录视图agian。请帮我解决问题
答案 0 :(得分:0)
尝试更改此行
if ($this->session->userdata('user_id')) {
与此一起
if ($this->session->has_userdata('user_id')) {