Error using an object in the session

Asked

Viewed 61 times

1

Galera is giving a strange error in my code, there is the value in the session but it informs this message.

[Wed Sep 02 13:55:17 2015] [error] [client 192.168.1.105] PHP Fatal error: main() [Function.main]: The script tried to execute a method or access a Property of an incomplete Object. Please ensure that the class Definition "Usuarioid" 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 in /opt/lampp/htdocs/Renan/suc_validacao.php on line 11, referer: http://127.0.0.1:58889/http-services/Emulator-webserver/ripple/userapp/x/C/Users/hotsystems/Appdata/Local/XDK/xdk-scratchdir/b9796bb6-a6c6-4479-94a3-7154a6043f83/Platforms/android/Assets/www/index.html

My class

<?php

/* Declara o bloco de definições do usuário logado SUC */

if (!class_exists('UsuarioID')) {

class UsuarioID {

    public $COD_IDENT_USUAR = -9999;
    public $COD_IDENT_IGREJ = -9999;
    public $TXT_NOMEX_USUAR = 'Anônimo';

    function setCOD_IDENT_USUAR($p_COD_IDENT_USUAR) {
        $this->COD_IDENT_USUAR = $p_COD_IDENT_USUAR;
    }

    function getCOD_IDENT_USUAR() {
        return $this->COD_IDENT_USUAR;
    }

    function setCOD_IDENT_IGREJ($p_COD_IDENT_IGREJ) {
        $this->COD_IDENT_IGREJ = $p_COD_IDENT_IGREJ;
    }

    function getCOD_IDENT_IGREJ() {
        return $this->COD_IDENT_IGREJ;
    }

    function setTXT_NOMEX_USUAR($p_TXT_NOMEX_USUAR) {
        $this->TXT_NOMEX_USUAR = $p_TXT_NOMEX_USUAR;
    }

    function getTXT_NOMEX_USUAR() {
        return $this->TXT_NOMEX_USUAR;
    }

    function sair() {
        $this->COD_IDENT_USUAR = -9999;
        $this->COD_IDENT_IGREJ = -9999;
        $this->TXT_NOMEX_USUAR = "Anônimo";
    }

}

}
?>

I have tried to implement the __Sleep method I have tried to serialize(); but in both cases it did not work, which may be more ?

  • You probably put some object in this session. I think this can be fixed if the object implements the magic methods __wakeup and __sleep

  • I could give you an answer as an example ?

  • Take a look at the answers to this question: http://answall.com/questions/75109/o-que-%C3%A9-essa-tal-classe-php-incomplete-class

  • How would this look in my case ?

1 answer

1


The error happens by not having include the class file in the document, the solution was very simple just add:

global $suc;
include 'suc.php'

On the page where I use the class in the session. No need to use serialize() and unserialize() much less the method __sleep. Error solved when adding a include 'suc.php' which is my class.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.