I am trying to load the cookie helper in my pre_controller hook for a ‘remember me’ function on our site. I thought that creating an instance of the CI object with $ci =& get_instance(); would allow me to access to loading helpers but this is not the case.
Thoughts?
$ci =& get_instance();
$ci->load->helper('cookie');
// does not load
The
pre_controllerhook executes before the super object has been fully constructed, soget_instance()can’t work – the static object it returns a reference to hasn’t yet been initialized.Consider using the
post_controller_constructorhook instead; your controller’s constructor will have executed, and the CI super object will be available for use.