Codeigniter重定向无法正常工作

el_*_*_le 3 php codeigniter

为什么不重定向在这里工作.我正在调用未定义的函数redirect().

class Login extends CI_Controller {

    function index() {

        parent::__construct();
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->view('login_view');        

    }

    function authenticate() {

        $this->load->model('user_model');
        $query = $this->user_model->authenticate();

        if($query) {

            $data = array(
                'username' => $this->input->post('username'),
                'is_logged_in' => true
            );

            $this->session->set_userdata($data);
            redirect('/site/news_feed');

        }
        else {

            $this->index();

        }

    }

}
Run Code Online (Sandbox Code Playgroud)

jon*_*ohn 16

authenticate()方法上方的顶部更改为此...

class Login extends CI_Controller {

    function __construct()
    {
        // this is your constructor
        parent::__construct();
        $this->load->helper('form');
        $this->load->helper('url');
    }

    function index()
    {
        //this is only called when someone does not specify a method...
        $this->load->view('login_view');        
    }
...
Run Code Online (Sandbox Code Playgroud)

我强烈建议将这两个助手自动加载,因为他们几乎要求使用......