0

I have an object inside $_SESSION. When I try to modify the object I get __PHP_Incomplete_Class Object.

Here's my code:

<?php
session_start();
$_SESSION['user']->lang = $_GET['lang'];

2 Answers2

1

Its very likely that there is an object in the serialised session, but the system hasn't seen the class definition. 'require'ing it should allow it to be properly built.

Alister Bulman
  • 34,482
  • 9
  • 71
  • 110
0

First of all a tip: Enable notices in your error reporting when you are developing and debugging issues. PHP tells you about problems. To give you an example of that I tried to reproduce your issue and create a class name User that is missing when unserializing:

Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "User" 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

As you can see such a method already tells you which concrete class definition is missing and potential ways to solve the issue.

hakre
  • 193,403
  • 52
  • 435
  • 836