title: Use session data in Hook in CodeIgniter 2.1.0
body: <p>I am using CodeIgniter with version 2.1.0. I want to use Hooks for login authentication. That means I want in every controller check the session data if loggedin or not. So I want to use hooks. I do the following code for doing that:</p>
  
  <h3>In config file</h3>
  
  <pre><code>$config['enable_hooks'] = TRUE;
  </code></pre>
  
  <h3>In file <code>hooks.php</code></h3>
  
  <pre><code>$hook['post_controller_constructor'][] = array(
                                 'class'    =&gt; 'SessionData',
                                 'function' =&gt; 'initializeData',
                                 'filename' =&gt; 'loginHelper.php',
                                 'filepath' =&gt; 'hooks',
                                 'params'   =&gt; array()
                                 );
  </code></pre>
  
  <h3>In file <code>loginHelper.php</code></h3>
  
  <pre><code>class SessionData{
      var $CI;
  
      function __construct(){
          $this-&gt;CI =&amp; get_instance();
      }
  
      function initializeData() {
  
          // This function will run after the constructor for the controller is ran
          // Set any initial values here
          if (!$this-&gt;session-&gt;userdata('username')) { // This is line 13
              redirect('login');
          }
      }
  }
  </code></pre>
  
  <p>But it throws the following error:</p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Notice
  
  Message: Undefined property: SessionData::$session
  
  Filename: hooks/loginHelper.php
  
  Line Number: 13
  </code></pre>
  
  <p>How can I solve this?</p>