CodeIgniter Forums

Full Version: Accessing Session in a custom helper file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I am trying to access the session object in a custom helper file. But an error is thrown when calling


Is there another way to access it?


El Forum


You'll need to get an instance of the Code Igniter object to do that.

You can make a variable called $CI in your contruct method, like this:
$CI =& get_instance();

Then to get the session you would then replace $this, with $CI, such as:

Hope this helps Smile