Welcome Guest, Not a member yet? Register   Sign In
Login System - Code Igniter just makes things excessively complex..
#9

[eluser]tomclowes[/eluser]
Many Thanks - I am getting my head around this (gradually).

WanWizard - thanks for the code. When presented like that it does seem pretty simple.

So in MY_Controller I have:

Code:
<?php

class  MY_Controller  extends  Controller  
{

    function MY_Controller ()  
    {
        parent::Controller();
        
    }
        
        
    function is_logged_in()
    {
        $session_id = $this->session->userdata('session_id');
    

        if($this->session->userdata('logged_in') == TRUE)
        {    
        
        return true;
    
        }
        else
        {
        return false;
        }
    

    }
}


My only slight confusion is this bit:

Code:
function MY_Controller ()  
    {
        parent::Controller();
        
    }

is the construct right.. (PHP 5 style) which loads all the properties of CodeIgniter?


So.. I have a function which checks log in.

Then in each of my controllers I place the following:

Code:
if ($this->is_logged_in())
    {
        $this->load->model('user_model');
        $data['user']=$this->user_model->user_details();

    }

$data is then passed to my header view.

That works great - of course the assumption is that I place the above in each individual controller.


On some pages however I want to output a username in the footer view or main page body view. Is there anyway of defining an array variable $user in MY_Controller which can simply be accessed in any view without anything having to be passed?

Thanks for all the help.


Messages In This Thread
Login System - Code Igniter just makes things excessively complex.. - by El Forum - 08-15-2010, 12:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB