Reply to Re: $_SESSION / $HTTP_SESSION_VARS behaviour

Your name:

Reply:


Posted by Michael Windsor on 11/03/06 14:01

Pedro Graca wrote:
> Michael Windsor wrote:
>> if I [...] put "$HTTP_SESSION_VARS = $_SESSION" after
>> session_start(), it stops $_SESSION behaving properly [...]
>>
>> Could this be a bug in PHP?
>
> My PHP does not exhibit that behaviour.
> Can it be that you have /something else/ in your code responsible for
> the behaviour you describe?
>
[snip code]

Your code on my web server exhibits the behaviour I would expect, but it
doesn't quite test the problem I'm having. If your code is amended as
follows:

<?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.

[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

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