Reply to Re: $_SESSION issue

Your name:

Reply:


Posted by Justin Koivisto on 12/21/05 21:37

Tom wrote:
> I put together a code that checks for 2 post variables then stores them
> in a multi-dim $_SESSION array, something like this:
>
> If ( isset($_POST['value_a'] && isset($_POST['value_b']) )
> {
> $_SESSION['value']['a'] = $_POST['value_a'];
> $_SESSION['value']['b'] = $_POST['value_b'];
> }
>
> The problem was that $_SESSION['value']['b'] was being overwritten with
> the value for 'a' so that both $_SESSION['value'] vars ended up being
> the same (i.e. $_POST['value_b']. I thoroughly tested it to confirm
> that this was what happening.
>
> I solved the problem by changing the $_SESSION vars to
> $_SESSION['value_a'] and $_SESSION['value_b'].
>
> This was PHP 5, the WAMP package -- I know it's not the latest update
> of PHP 5.
>
> My question: is this a bug (perhaps since fixed) or is there a reason
> this would be expected behavior?

The only way that I forsee this being expected behavior is if
$_POST['value_a'] == $_POST['value_b']

Usually when I am assigning an array to a session key, I will use:

$_SESSION['key'] = array('a'=>$a, 'b'=>$b);

I have never had any problems using either method, and tested that on my
two 5.1.1 installs which worked fine.

--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com

[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

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