[PHP-DEV] Re: PHP 4.0 Bug #8433 Updated: Objects are not held in a session From: Ruben Frijns (ruben <email protected>)
Date: 12/28/00

----- Original Message -----
From: Bug Database <php-dev <email protected>>
To: <info <email protected>>
Sent: Wednesday, December 27, 2000 11:30 AM
Subject: PHP 4.0 Bug #8433 Updated: Objects are not held in a session

> ID: 8433
> Updated by: jmoore
> Reported By: info <email protected>
> Old-Status: Open
> Status: Feedback
> Bug Type: *Session related
> Assigned To:
> Comments:
>
> Can you please try with 4.0.4. There were various session/object fixes in
this release.
>
> James
>

I found out what's wrong. Though i don't know if it's a bug. But when you're
within a function you cannot do anything with session variables. When you're
outside a function it's not a problem to use them.

For example

<?PHP

$name = $session["name"];
print ("Name: ".$name );

dosomething();

function dosomething() {

    $name = $session["name"];
    print ("Name: ".$name );

}

?>

The first line would work and print the name (assuming the $session["name"]
array would have a value). If you would call the function then you will not
see the name on your screen. You will have to provide the session variable
as an argument with the function and return any values and use these values
to update session variables.
This way things work fine.
I don't know if this is PHP typical and should be like this or wether it's a
bug.

Kind regards,

Ruben

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>