I want to get an id from a user that is recorded in the session, I'm trying to serialize the object when it's created:
$_SESSION['usuario'] = serialize($objUsuario);
and to recover tried to use:
echo unserialize($_SESSION['usuario'])->getIduser();
return error:
Fatal error: main (): The script tried to execute a method or access to property of an incomplete object. Please ensure that the class definition "pojoUsuario" of the object you are trying to operate on is loaded before unserialize () gets called or provide an autoloader to load the class definition in
If I give a var_dump($_SESSION['usuario']); die();
returns:
add-data.php:4:string 'O:11:"pojoUsuario":8:{s:19:"�pojoUsuario�iduser";s:1:"1";s:21:"�pojoUsuario�username";s:8:"nanous";s:18:"�pojoUsuario�senha";s:32:"1f32aa4c9a1d2readssdsdsdsddds6a04";s:18:"�pojoUsuario�email";s:20:"[email protected]";s:25:"�pojoUsuario�frasesecreta";s:14:"dogs";s:21:"�pojoUsuario�resposta";s:4:"S#hu";s:17:"�pojoUsuario�flag";s:1:"1";s:22:"�pojoUsuario�datasenha";s:10:"2018-07-24";}' (length=398)
I need to get the data stored in the session, such as username and iduser and I'm not getting it.