I want to extend the default controller, in order to enforce login. I did the following
- Created a file in application/core/MY_Controller.php
- Filled it as bellow
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Controller extends CI_Controller{
public function __construct() {
parent::__construct();
if (!$this->ion_auth->logged_in())
{
// redirect them to the login page
redirect('auth/login', 'refresh');
exit;
}
}
}
Somehow, the code in __construct is not executed. I also do not get any error. I can see that the MY_Controller.php file is read. When I put plain text in the file, this plain text is shown as output in the browser.
I hope somebody is able to help me
.