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

[eluser]steven2[/eluser]
Ok some I'm very new to CodeIgniter, so please bear with me.

I'm fooling around with extending the default controller and I'm trying to figure out if I'm doing something wrong that would cause the constructor that I extended to not correctly be called.

So I auto-load the "session" library in the config file.

This is the code in "MY_Controller.php"
Code:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');


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

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

This is the Code in my "Welcome Controller"

Code:
<?php

class Welcome extends AuthenticatedController {
    function __construct()
    {
        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');
    }
}

When I load the welcome controller I don't get any error messages, but
Code:
$this->session->userdata('tester')

isn't being correctly set by the constructor in MY_Controller.php. Anyone know why this might be. I'm sure I'm doing something basic wrong. By the way I'm using PHP 5.2.


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