php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27226 associative arrays as session variables
Submitted: 2004-02-11 17:43 UTC Modified: 2004-02-12 10:05 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: dayal at capital-merchant dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.2 OS: Unix
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dayal at capital-merchant dot com
New email:
PHP Version: OS:

 

 [2004-02-11 17:43 UTC] dayal at capital-merchant dot com
Description:
------------
PHP Version: 4.3.2
------------------
Hi,

I am using an associative array as a session variable.
Randomly this variable fails in the sense that all values corresponding to the keys are lost. 
To see if this problem is specific to associative arrays I have added another simple variable to the session. The application is able to retrieve this other variable from the session all the time, even when the associative array fails.

Is there any problem using associative arrays as session variables in php??

Reproduce code:
---------------
<?php

session_start();
$ar = array();
$ar["name"] = "xxxx";
$ar["password"] = "yyyyy";
$_SESSION["arrayvariable"] = $ar;
$_SESSION["numericvariable"] = 30;

Header("Location: test2.php");

?>


Expected result:
----------------
test2.php
---------

<?php
session_start();
echo "Your name: ".$_SESSION["arrayvariable"]["name"];
echo "Numeric value: ".$_SESSION["numericvariable"];
?>

Expected Result:
---------------

Your name: xxxx
Numeric value: 30

Actual result:
--------------
Your name: 
Numeric value: 30

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-11 19:59 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

Works (and has worked) fine with PHP 4.3.4 in production since release. (heavily using sessions and also storing associative arrays in them)

 [2004-02-11 21:57 UTC] dayal at capital-merchant dot com
So was this bug present in 4.3.2 and has been rectified in 4.3.4? If not, what could be the reason why associative arrays are failing when used as session variables in my case?

I just want to confirm the above before upgrading my php version.

Thanks in advance
Dayal
 [2004-02-12 10:05 UTC] sniper@php.net
Read the NEWS file. I don't know if this was specifically fixed in it or if it was some side-effect of some other bug that was fixed or if you're doing something wrong. I can just say that this works fine in PHP versions >= 4.3.3 (used in one other host I have some stuff running on)

We have no resources to support old versions anyway. If you say you're using any older PHP version than the latest release it causes the report to be bogus automatically.

 [2004-02-17 08:25 UTC] pappkamerad at decoded dot net
hmmm... i've the same problem here.
installed horde framework with ingo-filter manager. this is using hashes like $_SESSION['ingo']['edit']. example: if a edit link is clicked, than this happens in the target script:
---
$_SESSION['ingo']['edit'] = $id;
header('Location: ' . Horde::applicationUrl('rule.php'));
---
if register_globals is off all works fine. if it is "on", the $_SESSION['ingo']['edit'] variable is not defined in the rule.php script.
now if i reload the page (F5) everything is there...
php version is 4.3.4
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 16:01:30 2024 UTC