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

[eluser]steven2[/eluser]
[quote author="Dam1an" date="1245560120"]That's not what I meant to do
Instead of calling the constructor in AuthenticatedController you should leave it as it was (__construct) and change the call from within the welcome controllers constructor to be parent::__construct()

As it is at the moment, the 'constructor' in the AuthenticatedController isn't actually a constructor, as it's not the same name as the class (PHP4 syntax) or __construct (PHP5 syntax)

Make sense?[/quote]

Yes it makes sense and works perfectly. And thank you soo much for your help!

MY_Controller.php

Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');


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

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

Welcome Controller

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

This works exactly as I expected it to, but seems to conflict with the userguide http://ellislab.com/codeigniter/user-gui...nstructors which says

Quote:In PHP 5, constructors use the following syntax:
<?php
Code:
class Blog extends Controller {

       function __construct()
       {
            parent::Controller();
       }
}
?>

This is probably where my confusion is coming from. Am I misreading what the user guide is saying?


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