Are you unable to retrieve session value in CodeIgniter either in localhost or while switching controller. If so, this article is for you.
Here are the scenarios you might be getting issue.
If you are getting issue as mentioned above, won’t worry, you will be able to fix it. But before that, did you search for this issue. Once you search you will get following fixes. So, before my answer, try to attempt these steps.
Store your data in session
$data = array( 'user_id' => $row['user_id'], 'username' => $row['username'] ); $this->session->set_userdata($data);
Get session data
$userID = $this->session->userdata('user_id'); $username = $this->session->userdata('username');
Don’t forget to add session library in autoload
$autoload['libraries'] = array('session');
load in controller
Did above steps work? Nope? No program. Let’s try new style which is really awesome. Following these steps
Now run your project. You might get issues. If so, just copy newly created files and folder in old_system folder to new system folder.
And that’s all. Isn’t that too easy? I hope so. Well, using this approach I was able to fix my problem. And I hope this fixed yours as well. If not, just let me know and I will try to help you.
If this helped you, don’t forget to share this post so that others might get help. That would be highly appreciated.