I've got a helper file that requires accessing some session data and so it looks like this (this isn't the actual file contents, but rather a simplified version with the same level of necessary detail):
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$CI =& get_instance();
if (!is_null($CI->session->userdata('name')) {
if ( ! function_exists('sayHi'))
{
function sayHi() {
echo "Hello, " . $CI->session->userdata('name') . "!";
}
}
}
So let's say I'm looking at pages/home and this function is called when I submit to the same page - it's called by the model. No errors when the function is not called. When the function is called, it gives me this:
Message: Undefined variable: CI
What's going on?