Welcome Guest, Not a member yet? Register   Sign In
hook is not working, $CI =& get_instance() not working
#1

[eluser]Alpha[/eluser]
Code:
<?php
class Auth {

    var $CI;

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

     $this->CI->load->helper('url');
     $this->CI->load->library('session');

        if(!$this->CI->session->userdata("logged_in") && $this->CI->uri->uri_string != "/user/login")
            redirect('user/login', 'location');

    }
}

?>

i used the above code for $hook['pre_controller']

i get the following error

Fatal error: Call to a member function userdata() on a non-object in D:\....\application\hooks\authenticate.php on line 12

tried to comment the if condition and i got this
Fatal error: Call to undefined function redirect()

its like CI superobject was not referenced

need help, tnx




Theme © iAndrew 2016 - Forum software by © MyBB