'How to use hooks in CodeIgniter

How to use hooks in CodeIgniter like

class SessionData{
    var $CI;

    function __construct(){
        $this->CI =& get_instance();
    }

    function initializeData() {
          // This function will run after the constructor for the controller is ran
          // Set any initial values here
          if(!$this->session->userdata('username')){    //this is line 13
             redirect('login');
          }
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source