Bilal Bilal - 4 months ago 29
PHP Question

How can i set codeigniter sessions to globally accessible?

I am storing

in session user data, but the user data is only available in one controller. I want to make the CodeIgniter sessions globally accessible.

I have this code

$custom_data = array(
'userid' => $user_id,
'loggedin' => TRUE


I just loaded session library, and I have also used some hacks after searching around, but nothing is working the way I would like. How can I tackle this properly?


Hang on, there's nothing about using sessions in CodeIgniter anywhere on the internet?

This framework HAS been out for 5 years so I doubt that's the case. Maybe you've not described your problem very well?

By globally accessable if you mean you want to get it in other controllers then use:


That will return your value.

If by globally available you mean you want it available in other PHP files (not CodeIgniter) then thats a totally different thing. You need to use native PHP sessions to work natively with PHP and CodeIgniter sessions to work with CodeIgniter sessions. Simple! :)