Description
I am trying to add a custom object called ReviewHolder
to a session. This is being done in the "review" controller. The ReviewHolder
class is included in the classes/controller/review.php
file. I am using Kohana version 3.2.
The code
$session = Session::instance();
$reviewholder = $session->get('reviewholder');
if($reviewholder == null) {
$session->set('reviewholder', new ReviewHolder());
}
The problem
The problem is that after I execute the above code, the session gets corrupted and almost the entire website stops functioning correctly. This is the error message on every page:
Session_Exception [ 1 ]: Error reading session data.
The weird part
All pages that are loaded from the "review" controller are still all function correctly! It looks like the above code is messing up every other session in the application...
Debug
I have debugged the session to see if the object is set correctly with the following code:
echo Debug::vars($session->get('reviewholder'));
This shows the object correctly, so it has been set in the session.
Can someone help me out here? Thanks!
It doesn't really matter whats inside the session file.
All i know is that you can only store objects that are serialized in the session.
After serializing you can store it in an session and to make it an object again for later use. You can unserialize the serialized object.
Hope this helps!