2017-01-05 8 views
0

私は現在、Codeigniter 3.1.2とIon Authを使用しています。私はログインしてダッシュボードページを見ることができますが、顧客ページなど、ログインする必要がある別のページを表示しようとすると、私はいつもログインページにリダイレクトされます。Ion Auth + Codeigniter logged_inは常にログインにリダイレクト

コントローラ

public function __construct(){ 
    parent::__construct(); 
    $this->load->library('form_validation'); 
    $this->load->library('session'); 
    $this->load->helper('form'); 
    $this->load->helper('url'); 
    $this->load->model('CRUD'); 

    if (!$this->ion_auth->logged_in()) { 
     redirect('User/index'); 
    } 
} 

public function index(){ 
    $this->load->helper('form'); 
    $this->load->view('login'); 
} 

public function dashboard(){ 
    $this->load->view('dashboard'); 
} 

public function customerPage(){ 
    $data['customer'] = $this->CRUD->getCustomers(); 
    $this->load->view('customer', $data);   
} 

public function materialPage(){ 
    $data['material'] = $this->CRUD->getMaterials(); 
    $this->load->view('material', $data); 

} 

おかげで、 CHTRK

答えて

0
public function __construct(){ 
parent::__construct(); 
$this->load->library('form_validation'); 
$this->load->library('session'); 
$this->load->helper('form'); 
$this->load->helper('url'); 
$this->load->model('CRUD'); 

if (!$this->ion_auth->logged_in()) { 
    redirect('User/index'); 
} 

"!の$ this - > ion_auth-> LOGGED_IN()" それはすべての時間に実行されますので、コンストラクタの外にこれを使用しています。メソッドで毎回呼び出す別のメソッドを作成する必要があります。インデックスに使用しないでください

関連する問題