title: CodeIgniter basic controller extends
body: <p>I want to extend basic controller by my own. This is code of file <code>MY_Secure.php</code> which i put in <code>application/libraries</code> </p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  Class MY_Secure extends CI_Controller {
    public function __construct() {
      parent::__construct();
      if(!$this-&gt;session-&gt;userdata('status') == 'admin') {
          $data['message'] = '&lt;p class="error"&gt;You shold login in admin area&lt;/p&gt;';
          $this-&gt;load-&gt;view('admin/login', $data);
      }
    }
  }
  ?&gt;
  </code></pre>
  
  <p>And here is my controller in <code>application/controllers/category.php</code></p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Category extends MY_Secure {
  
  function __construct()
  {
      parent::__construct();
  }
  
   public function index()
  {
   $data['login'] = $this-&gt;session-&gt;userdata('login');
   $data['status'] = $this-&gt;session-&gt;userdata('status');
  
   $this-&gt;load-&gt;model('categories_model');
   $data['main_categories'] = $this-&gt;categories_model-&gt;get_main_categories();
  
   $this-&gt;load-&gt;view('admin/headers/main', $data);
   $this-&gt;load-&gt;view('admin/category');
   $this-&gt;load-&gt;view('admin/footer/main');
  }
  ?&gt;
  </code></pre>
  
  <p>But i have an error <code>Fatal error: Class 'MY_Secure' not found in Z:\home\ci.local\www\application\controllers\admin\category.php on line 3</code> How can i avoid this error? What i do wrong?</p>