[eluser]Samus[/eluser]
[quote author="FrankStar" date="1334599166"]I'm using template views with embedded content views inside. So far so good; everything works pefectly. Now when a user logs in, I store the useful data in my session so it can be shared through the entire site. Then instead of calling the session data directly from the template view, I pass it through the controller like this:
Code:
$data['main_content'] = 'pages/profile'; // The subview with the content
$data['userdata'] = $this->session->userdata; // The logged in user info
$this->load->view('mytemplate', $data);
However, as you can imagine this can become quite repetitive since I have to call this for every single pages.
How would you approach this situation? I don't have lot of experience using CI and designing login systems so any input would be greatly appreciated![/quote]
Put it in your controller constructor.
Code:
function __construct() {
parent::__construct();
$data['userdata'] = $this->session->userdata;
}