Why add a CodeIgniter constructor that generates a 500 error

Hi everyone, I have a site controller code as shown below ... when I try to execute this code, I get a strange problem. If I select the __construct () function, everything will be fine for me, but as soon as I add that the constructor function I get an error of 500 internal server errors, can anyone help me?

<?php

class site extends CI_Controller
{

    function __construct()
    {
       parent::CI_Controller();
       $this->Logged_in();
    }


    function after_logging()
    {
        $this->load->view('home');
    }

    function Logged_in()
    {
        $is_logged_in = $this->session->userdata('is_logged_in');
        if(!isset($is_logged_in)|| $is_logged_in != TRUE)
        {
            die();
        }
    }

}
+3
source share
1 answer

Is this CI 2.0?

In this case, use this for the constructor:

public function __construct()
{
    parent::__construct();
        // your code
}
+6
source

All Articles