|
|
Posted by fabamb on 08/07/07 21:00
Maybe your session storage have not enough space to save serialization
of $User and then when session manager tries to unserialize it from
session storage it finds an incomplete object and returns null.
Or your memory_limit value in php.ini is too low and session is
greater than it, try to increase it at first
(mind to restart apache).
On 7 Ago, 22:46, kvnsm...@hotmail.com wrote:
> I've got a section of code as follows that checks to see if variable
> <$User> is registered. If it isn't, then it registers it and calls
> its constructor to actually create it. If it is, then it checks to
> see if it's an object, and if it's not an object it prints an error
> message and aborts the program.
>
> I've been able to document that the first time through the program it
> takes the first branch, and therefore registers the variable and cre-
> ates an object that it assigns to <$User>. The second time through
> the program it detects that <User> is registered, but when I call
> <is_object( $User)> I get <false>, and in fact on inspection it turns
> out that the second time through this code <$User> turns out to be
> <null>.
>
> My boss tells me that this code is working on one of our machines, but
> on my machine I keep getting this error message. Can anybody tell me
> why PHP is recognizing that this variable is registered but that it's
> forgetting that it's an object and considers it to have a <null> va-
> lue? Is it possible for a variable to be initialized with a construc-
> tor one time through a PHP file, be registered, and then for it to be
> <null> the second time through the PHP file? I've gone all the way
> through all the PHP code we have and haven't found a single place that
> sets <$User> to <null>.
>
> ---Kevin Simonson
>
> "You'll never get to heaven, or even to LA,
> if you don't believe there's a way."
> from _Why Not_
>
> ####################################################################
>
> // Register session variable "User" as an object
> if( !session_is_registered( "User" ) ) {
> session_register( "User" );
> $User = new User();} else if( !is_object( $User ) ) {
>
> system_error( "Unable to instantiate User object." );
>
> } // end if
[Back to original message]
|