title: CodeIgniter custom library error: Call to a member function on a non-object
body: <p>I'm trying to build a custom library which will contain functions that would be available through the whole site. Inside <code>/application/libraries</code> I've made a new file <code>CustomFuncts</code>:</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  /**
   * @brief CommonFuncts      
   * This class is used to provide common user functions to the whole application.
   *
   * @version 1.0
   * @date May 2012
   *
   * 
   */
  class CommonFuncts extends CI_Controller {
  
   protected $ci;
  
  /**
   * function constructor
   */
  function __construct()
  {
      $this-&gt;ci =&amp; get_instance();
  }
   /**
  * @brief checkCookie
  * 
  * Checks for a previous cookie, and if exists:
  * @li Loads user details to CI Session object.
  * @li Redirects to the corresponding page.
  * 
  */
  public function verificaCookie(){
      $this-&gt;ci-&gt;load-&gt;view('index');
  }
   }
  /* End of file CommonFuncts.php */
  /* Location: ./application/libraries/CommonFuncts.php */
  </code></pre>
  
  <p>And in controller <code>welcome.php</code>:</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Welcome extends CI_Controller {
  
  /**
   * Index Page for this controller.
   *
   * Maps to the following URL
   *      http://example.com/index.php/welcome
   *  - or -  
   *      http://example.com/index.php/welcome/index
   *  - or -
   * Since this controller is set as the default controller in 
   * config/routes.php, it's displayed at http://example.com/
   *
   * So any other public methods not prefixed with an underscore will
   * map to /index.php/welcome/&lt;method_name&gt;
   * @see http://codeigniter.com/user_guide/general/urls.html
   */
  public function index()
  {
      $this-&gt;load-&gt;library('commonFuncts');
      $this-&gt;commonFuncts-&gt;verificaCookie();  
  }
  }
  
  /* End of file welcome.php */
  /* Location: ./application/controllers/welcome.php */
  </code></pre>
  
  <p>I'm getting the following error message:</p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Notice
  
  Message: Undefined property: Welcome::$commonFuncts
  
  Filename: controllers/welcome.php
  
  Line Number: 23
  
  Fatal error: Call to a member function verificaCookie() on a non-object in
  /var/www/vhosts/unikodf.com/httpdocs/application/controllers/welcome.php on line 23
  </code></pre>
  
  <p>I've tried many things, including extending in the library the <code>CI_Controller</code>and using <code>$this-&gt;load-&gt;view' instead of</code>$this->ci->load->view` but still I'm getting the same message.</p>