Welcome Guest, Not a member yet? Register   Sign In
Howto extend default controller
#1

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 Smile.
Reply


Messages In This Thread
Howto extend default controller - by wjonker - 10-23-2018, 07:12 AM
RE: Howto extend default controller - by jreklund - 10-23-2018, 11:19 AM
RE: Howto extend default controller - by wjonker - 10-25-2018, 12:51 AM
RE: Howto extend default controller - by neuron - 10-25-2018, 01:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB