Reply to Re: $_SESSION / $HTTP_SESSION_VARS behaviour

Your name:

Reply:


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()?

[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

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