Welcome Guest, Not a member yet? Register   Sign In
Newb Question on Exteneding Default Controller/Sessions
#3

[eluser]steven2[/eluser]
[quote author="Dam1an" date="1245558320"]Hi, welcome to CI

In your welcome controller, in the construct, you're calling parent::Controller, and yet you don't have a Controller function in the parent, you have a __construct();

Also, I'm not sure if you can name the controller differant from the file name, but it's recommended to make the class name the same as the file name, so in this case, call the class MY_Controller and have your controller extend that[/quote]

Thanks. I switched up the names of the Controller, I guess if I want to override the default controller I have to called the function "Controller". Makes perfect sense and now works.

Code:
class AuthenticatedController extends Controller
{
  function Controller()
  {
    parent::Controller();
  

    $this->session->set_userdata('tester', 'testerasdf');
    //return;
    /*
    if( ! $this->session->userdata('logged_in_value'))
    {
       redirect('login_controller');
    }*/
  }
}

And in Welcome Controller it is now:

Code:
class Welcome extends AuthenticatedController {
    function Welcome()
    {
        
        parent::Controller();    
        //$this->session->set_userdata('tester', '652');
        echo "'" . $this->session->userdata('tester') . "kk'";
        if ($this->session->userdata('tester') == false)
            echo "Does not exist in session.";
    }
    
    function index()
    {
        $this->load->view('welcome_message');
    }
}

Which makes much more sense to me, but why then does it say http://ellislab.com/codeigniter/user-gui...nstructors

that for PHP 5 you have to use function __construct() as your constructor?


Messages In This Thread
Newb Question on Exteneding Default Controller/Sessions - by El Forum - 06-20-2009, 05:16 PM
Newb Question on Exteneding Default Controller/Sessions - by El Forum - 06-20-2009, 05:25 PM
Newb Question on Exteneding Default Controller/Sessions - by El Forum - 06-20-2009, 05:46 PM
Newb Question on Exteneding Default Controller/Sessions - by El Forum - 06-20-2009, 05:55 PM
Newb Question on Exteneding Default Controller/Sessions - by El Forum - 06-20-2009, 06:25 PM
Newb Question on Exteneding Default Controller/Sessions - by El Forum - 06-20-2009, 06:30 PM
Newb Question on Exteneding Default Controller/Sessions - by El Forum - 06-20-2009, 07:41 PM
Newb Question on Exteneding Default Controller/Sessions - by El Forum - 06-21-2009, 02:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB