I am working with Codeigniter PHP.
I want if admin not login then he can't see admin panel pages. For this i created helper.
The Code is working if I put condition is every function but if I use this code in "constructor" then redirect to home page but also showing "login" page after home page.
Where I am wrong ?
Here is my code (using in one of my function which is working )
public function admin_offers(){
if (!is_logged_in()) {
$this->index();
//die();
}
else {
$data['offers']=$this->db->get('offers')->result();
$this->load->view('admin/special-offers',$data);
}
}
And here is my code in constructor, which is not working for me.
public function __construct() {
parent::__construct();
$this->load->model("stores_model");
$this->load->library("pagination");
$this->load->library('encryption');
is_logged_in();
if (!is_logged_in()) {
$this->index();
}
}