Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why adding a CodeIgniter constructor producing error 500

Hello everyone I have a site controller code as below..... when I try to execute this code I get a weird problem, If I take out the __construct() function everything works pretty well for me, but, as soon as I add that constructor function I get the error 500 internal server error can any one help me out ??

<?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();
        }
    }

}
like image 502
koool Avatar asked Sep 13 '26 18:09

koool


1 Answers

Is this CI 2.0?

In that case, use this for the constructor:

public function __construct()
{
    parent::__construct();
        // your code
}
like image 176
Joris Ooms Avatar answered Sep 15 '26 11:09

Joris Ooms



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!