Reply to Re: [PHP] Re: Objects in Arrays (without the READ prompt)

Your name:

Reply:


Posted by Jochem Maas on 11/11/99 11:15

Mathieu Dumoulin wrote:
> Stuart Nielson wrote:
>
>> Sorry to everyone about the stupid READ notification on the posting. I

some people on this list see it as sport/duty to send a reply to all
read-notifications from list posts... I wonder how many you got :-)

>> completely forgot that it was enabled. This one shouldn't have that
>> problem.
>>
>>
>> I am using PHP version 4.3.4.
>>
>> I'm creating an authorization module that uses a users object, that
>> includes the username, usertype, etc. I want to store this in a session
>> variable (i.e. $_SESSION['objects']['auth'] = new Authorization();) so
>> that I can keep the information from page to page. However, I get an
>> error that it is an incomplete class everytime I try to access a
>> function from the object like this:
>> "$_SESSION['objects']['auth']->Login();". It works fine when it's not
>> stored in the array. Is this a PHP 4 issue? Or is there something I'm
>> doing wrong?
>>
>> Any pointers would be helpful. If this doesn't work, I'll have to
>> rework things to just store in arrays.

very general pointer: google.
e.g.: http://www.google.nl/search?q=php4+objects+in+session


>>
>> Stuart
>>
> Objects can't be stored in sessions, what you could do is register a

BULLSHIT. (or maybe you use a version of PHP thats before my time, like say 3.0)

> shutdown function using register_shutdown_function(<functionname>) and
> create a custom function that would use serialize() to serialize your
> object.
>
> When the system starts a new you could unserialize() this session
> variable back into an array.

anything in the $_SESSION global will automatically be serialized.
BUT in order for PHP to restore you object fully you MUST include the
class definitions of all object you are storing in the session BEFORE
you call session_start().

I'll bet that if you did a var_dump() of $_SESSION['objects']['auth']
without changing/moving the ness. include statements you will find
that it is an object of type 'PHP_Incomplete_Object' (or something similar)...
and that all the member variables are actually set - its just that no
methods are defined for that object because the class definition was
not available at the time the object was unserialized by php.


>
> Mathieu
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация