2017-01-19 12:25



In my project, I have this line, in the core file:

$LoggedIn = isset($_SESSION['User']) ? unserialize($_SESSION['User']) : false;


and under the login method, it has the corrosponding:

$_SESSION['User'] = serialize($User);

User Repo:


When I try to access the $LoggedIn object, it gives me an error like this:

Fatal error: Uncaught Error: Cannot use object of type __PHP_Incomplete_Class as array in C:\xampp\htdocs\jalawebs\dev\webcofounder\web\controller\index\index.php:14 Stack trace: #0 C:\xampp\htdocs\jalawebs\dev\webcofounder\config\core.php(111): require() #1 C:\xampp\htdocs\jalawebs\dev\webcofounder\index.php(9): require('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\jalawebs\dev\webcofounder\web\controller\index\index.php on line 14
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • duandu8707 duandu8707 4年前

    This happens when you call to a property of an unserialized object that is not defined in the script itself.

    Creating a class like so new User() will invoke the autloader to load the script where unserialize() does not.

    You could do the following:

    $o = unserialize($yourstring);
    if(is_object($o) && class_exists(get_class($o))){ // invoke the autoloader
      echo $o->LoggedIn;

    Or just include the script directly with include_once() or require_once().

    点赞 评论 复制链接分享