3

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

}
1
  • 2
    did you try to use parent::__construct() instead of parent::CI_Controller()? Commented Jun 4, 2011 at 19:43

1 Answer 1

6

Is this CI 2.0?

In that case, use this for the constructor:

public function __construct()
{
    parent::__construct();
        // your code
}
Sign up to request clarification or add additional context in comments.

1 Comment

Looks like he's indeed on version 2, where Controller is renamed CI_Controller. @koool: User guide reference here: codeigniter.com/user_guide/general/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.