Welcome Guest, Not a member yet? Register   Sign In
Hooks en codeigniter 2.x
#1

[eluser]xoiv[/eluser]
Hi, I am studying the hooks following this tutorial:
http://www.noquieroprogramar.com/usando-...deigniter/

hooks file I have configured for:
Code:
$hook['pre_controller'] = array(
    'class'    => 'my_class',
    'function' => 'loggeado',
    'filename' => 'my_class.php',
    'filepath' => 'hooks'
);

The problem is that for some reason unknown to me, shows me the following error messages:

if I write in my_class:

Code:
function loggeado(){
   $CI =& get_instance();
   $CI->load->library('session');
   exit($CI->session->all_userdata());
}

Fatal error: Call to a member function library() on a non-object in /var/www/ci/application/hooks...


if I do well
Code:
function loggeado(){
   $CI =& get_instance();
   exit($CI->session->all_userdata());
}
Fatal error: Call to a member function all_userdata() on a non-object in /var/www/ci/application/hooks...

I do not wrong, the library is loaded by default session in autoload.php but even so I can not interact with the function.

sorry for my english..

I am doing wrong?
#2

[eluser]mejlo[/eluser]
Try to change
Code:
$hook['pre_controller'] = array(
   ...
);
to
Code:
$hook['post_controller_constructor'] = array(
   ...
);
#3

[eluser]xoiv[/eluser]
thanks friend, was it =)




Theme © iAndrew 2016 - Forum software by © MyBB