CI - 所有页面的公共变量?

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

Okay here's a better design for your views.

First, create a folder called include/, in this folder create a header.php, footer.php, template.php.

header.php

<html>
<head>JS - CSS - META</head>
<body>

<div>COMMON MESSAGE</div>

footer.php

<footer>FOOTER GOES HERE</footer>
</body>
</html>

template.php

$this->load->view('include/header.php');
$this->load->view($main_page);
$this->load->view('include/footer.php');

any controller:

$data['main_page'] = "hello_world"; // view/hello_world.php
$this->load->view('include/template',$data);

So in that way, you can create a common section that will be displayed on all pages by adding it to the header or the footer. If you want, you can also create another file in the include folder and then include it in the template so that it will be loaded automatically every where by only modified one file