I am trying to use a third party script and extract the logged in users userid. I am aware the CodeIgniter uses some sort of encrypted sessions. Can you please suggest how to get the userid. A simple $_SESSION does not seem to work.
I am basically running a separate script and i just want the session details i.e. the userid. But I do not want to modify this script as MVC model. I want to modify it as minimal as possible.
Sorry I am very new to CodeIgniter. Thank you for your time.
Depending if you auto-load the session library or not, we will need to include:
Then you should be able to use:
$session_id = $this->session->userdata('SessionID');
Does this get you what you need?
If you want to set a session variable, for example:
or use the array. It's quite easy if you read the docs. And the docs in Code Igniter are great!
$newdata = array( 'username' => 'johndoe', 'email' => 'email@example.com', 'logged_in' => TRUE ); $this->session->set_userdata($newdata);