Masoud Tavakkoli Masoud Tavakkoli - 4 months ago 15
PHP Question

hooks didn't load in codeigniter

I'm new in codeigniter, I want 2 page with the name of "login" and "admin"
i use hook and session to detect user is logged in or not, but unfortunately hook didn't load (Call) at all.
any idea?

My controller :

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Auth extends CI_Controller{

public function __construct(){
parent::__construct();
}


public function index(){

}
}




My hook :

<?php if ( !defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' );

class Auth_hook {

protected $CI;

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

public function index(){
print_r("hello!!");
}
}
}
?>


EDIT: And finally
hooks.php
:

$hooks['pre_controller']=array(
'class'=>'Auth_hook',
'function'=>'index',
'filename'=>'Auth_hook.php',
'filepath'=>'hooks'
);

Answer

Try this :

$hook['pre_controller']

Instead of this :

$hooks['pre_controller']