koool
koool

Reputation: 15537

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

}

Upvotes: 3

Views: 2423

Answers (1)

Joris Ooms
Joris Ooms

Reputation: 12048

Is this CI 2.0?

In that case, use this for the constructor:

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

Upvotes: 6

Related Questions