codeigniter - Calling another controller within a controller if already logged in -


i have login controller, check wether logged in or not so

if($logged_in){     $this->load->view('profile_view');  } else{     $this->index(); } 

like can see i'm loading view if im not logged in. instead of loading view i'd rather have load controller loads view, because want send data controller view.

so want this

 if($logged_in){     $this->load->controller('profile_controller');   } 

and in profile controller put this

function index(){     $logged_in =  $this->logged_in->is_logged_in();      if($logged_in){         $this->load->model('profile_model');         if($query = $this->profile_model->getalluserinfo()){             $data['records'] = $query;             $this->load->view('profile_view', $data);         }     }     else{         echo "you don't have access on page";     } } 

but seems loading controller controller isn't possible! how can create view while sending data it?

take @ how ben edmunds authentication library handles it.

if (!$this->ion_auth->logged_in())     {         redirect('auth/login');     } 

ion_auth lobrary - http://benedmunds.com/ion_auth/#logged_in


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -