|
Posted by Pedro Graca on 11/04/06 01:50
Michael Windsor wrote:
> <?php
> session_start();
>
> if (rand(0, 1)) {
>
> echo "Using copy of the \$_SESSION array...<br>\n";
>
> $COPY_SESSION = $_SESSION;
> if (rand(0, 1)) {
> echo "and not copying it back.<br>\n";
> } else {
> $_SESSION = $COPY_SESSION;
> }
> if (!isset($_SESSION['count'])) {
> $_SESSION['count'] = 0;
> }
> $val = ++$_SESSION['count'];
>
> } else {
>
> if (!isset($_SESSION['count'])) {
> $_SESSION['count'] = 0;
> }
> $val = ++$_SESSION['count'];
>
> }
>
> echo "Current value is $val.<br>\n";
> ?>
>
> counter increments are only shown on pages following a page where a copy
> is NOT taken of $_SESSION (i.e. the final else clause is executed),
> regardless of whether the copy of $_SESSION is written back to it or
> not. Note that all increments in this version of the code are made
> directly to the $_SESSION array, never to a copy: the counter *should*
> increment on every page load, as far as I can see. It doesn't on my system.
This amended script *always* increments the current value for me.
Can you post the result of phpinfo()?
Navigation:
[Reply to this message]
|