RE: [PHP] session variables and unset
| From: | Johnson, Kirk | Date: | Wed, 10 Apr 2002 15:48:37 +0000 |
| Subject: | RE: [PHP] session variables and unset | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-92410@lists.php.net to get a copy of this message | ||
I get '4', as expected, on v.4.0.6.
Kirk
> -----Original Message-----
> From: Valdas Andrulis [mailto:valdand@soften.ktu.lt]
> Sent: Wednesday, April 10, 2002 3:43 AM
> To: php-general@lists.php.net
> Subject: [PHP] session variables and unset
>
>
> Hello,
>
> I have 3 scripts:
>
> ## i2.php
> <?php
> session_start();
> $counter = 1;
> session_register("counter");
> header("Location: /i.php");
> ?>
>
> ## i.php
> <?php
> session_start();
> $counter = 0;
> ### uncomment this to see the difference
> # session_unregister("counter");
> session_register("counter");
> unset($counter);
> $counter = 4;
> session_register("counter");
> header("Location: /i1.php");
> ?>
>
> ## i1.php
> <?php
> session_start();
> print $counter;
>
> ?>
>
> When I open http://host/i2.php on my browser I get 0, though
> I expect it
> to be 4. If I uncomment session_unregister("counter"); I get 4 as
> expected.
>
> PHP version 4.1.2.
>
> Anyone can explain this behavior? Also can anyone try this with say
> 4.0.5 or older version of PHP?
>
> Good luck,
>
> Valdas