Reputation: 497
When I am trying to save object in session using codeigniter
<pre>
$this->session->set_userdata($user_info);
the following error is shown
Severity: Warning
Message: Illegal offset type
Filename: Session/Session.php
Where $user_info = stdClass Object(
[users_id] => 1
[users_firstname] => Ahmar
[users_lastname] => Arshad
[users_email] => [email protected]
[user_image] =>
[users_role] => 1
[users_deleted] => 0
);
</pre>
But when I convert that object into array and then store in session it works fine. Can anybody help me out. Thanks in advance
Upvotes: 0
Views: 667
Reputation: 12132
This error is happening because you are setting your session incorrectly.
You need to edit it in this format:
$this->session->set_userdata('user_info', $user_info);
Upvotes: 2