class My_Controller extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper('url'); $this->pageTitle = 'My Website'; } }
class My_Controller extends CI_Controller { public function __construct() { parent::__construct(); $this->load->library('session'); $this->loggedIn = $this->session->userdata('loggedIn'); } }Package library: session library Overall, the CI_Controller __construct function is a powerful tool in CodeIgniter for initializing controllers and setting up global variables and libraries for use throughout the controller. The examples above illustrate how it can be used to load helper and library packages and set up variables that can be easily accessed in other controller functions.