I am storing userid
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
);
$this->session->set_userdata($custom_data);
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:
$this->session->userdata('userid');
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! :)