I wish to display a variable that is stored in a session at the top of each page throughout my website. At the minute, on every single page, in the controller index()
I have;
$data['credits'] = $this->session->userdata('credits');
I havve created a seperate view for the navigation bar (where the variable will be displayed). I have called it vNav.php
. In vNav.php
I then do echo $credits
.
For every new view, I have to include the vNav.php
, but that also means in the other view's controllers, I have to set the $data['credits']
variable in the index()
function.
Is there a way in CI to do this automatically for me? So I don't have to have the same line of code in all my controllers?
Thanks