Incomplete class object PHP : __PHP_Incomplete_Class Object Session

Some time when we try to access session object we get the object class as __PHP_Incomplete_Class.

This happens when we try to initialize the session before loading the class definitions for the object we are trying to save into the session.
To say it sin simple, if a class definitions is not defined, PHP creates incomplete objects of the class __PHP_Incomplete_Class.

To avoid __php_incomplete_class object session error, every class definition must be included or defined before starting the session.

In other words we to have define or include the class before calling session_start. If we don’t, PHP’s session handler won’t know how to unserialize the instances of that class, and will end up with the __PHP_Incomplete_Class Object.

For example try to use like the below way :

Other way of solving is to regenerate the object

Leave a Reply

Your email address will not be published. Required fields are marked *