title: PHP - The script tried to execute a method or access a property of an incomplete object
body: <p>I'm using CI and I have a UserModel that selects the user based on login information and sets a userVO and add this userVO in a session like this:</p>
  
  <pre><code>$this-&gt;session-&gt;set_userdata('user', $userVO);
  </code></pre>
  
  <p>When I try to access this session it return me this error:</p>
  
  <pre><code>Message: main() [function.main]: The script tried to execute a method 
  or access a property of an incomplete object. Please ensure that the 
  class definition "UserVO" of the object you are trying to operate on 
  was loaded _before_ unserialize() gets called or provide a __autoload() 
  function to load the class definition.
  </code></pre>
  
  <p>I have found a "solution", I need CI to load the UserVO class before session class and it works.</p>
  
  <p>The problem is that I have lots os VO classes and I'll need them inside the session and is a bad thing to autoload them because I won't need them all at the same time.</p>
  
  <p>Is there any workaround?</p>
  
  <p>Thanks in advance for any help.</p>