[eluser]Phil Sturgeon[/eluser]
+1 for MY_Controller. On PyroCMS I use several types of controller classes. MY_Controller adds logic to ALL controllers then I have Public_Controller and Admin_Controller to add shared logic to the front and back ends respectively.
If you just want to do this on a per-controller basis or don't want the extra complication, just do this:
Code:
class something extends Controller {
function something() {
parent::Controller();
if($this->session->userdata('logged_in') === FALSE)
{
redirect('/');
}
}
function main()
{
$data['username'] = $this->session->userdata('email');
$data['firstN'] = $this->session->userdata('first_name');
$data['lastN'] = $this->session->userdata('last_name');
$data['city'] = $this->session->userdata('city');
$data['state'] = $this->session->userdata('state');
$this->load->view('mrmain/includes/header_view');
$this->load->view('admin/main_view', $data);
$this->load->view('mrmain/includes/footer_view');
}
}