#24202 [Bgs]: problem with array of objects stored in session vars

From: Date: Mon, 16 Jun 2003 14:40:51 +0000
Subject: #24202 [Bgs]: problem with array of objects stored in session vars
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-42040@lists.php.net to get a copy of this message
ID: 24202 User updated by: admin at nexusfor dot com Reported By: admin at nexusfor dot com Status: Bogus Bug Type: Session related Operating System: WIN NT PHP Version: 4.3.2 New Comment: second source correction: <? $b = $HTTP_GET_VARS["b"]; $_SESSION ["SESS"] = array_merge ($_SESSION ["SESS"], array ($b) ); print_r ($_SESSION ["SESS"]); reset ($_SESSION ["SESS"] ); $i = 0; while (list ($key, $val ) = each ($_SESSION ["SESS"] ) ) { echo $val; } ?> sorry for the mistake Previous Comments: ------------------------------------------------------------------------ [2003-06-16 08:51:56] admin at nexusfor dot com I'm sure that there's something wrong. this script shows the problem in 4.3.1/4.3.2 release for WIN <? class bogus { var $a; } $b = new bogus; $b -> a = $HTTP_GET_VARS["b"]; $_SESSION ["SESS"] = array_merge ($_SESSION ["SESS"], array ($b) ); print_r ($_SESSION ["SESS"]); reset ($_SESSION ["SESS"] ); $i = 0; while (list ($key, $val ) = each ($_SESSION ["SESS"] ) ) { echo $val->a; } ?> the scalar version just work file <? $b = $HTTP_GET_VARS["b"]; $_SESSION ["SESS"] = array_merge ($_SESSION ["SESS"], array ($b) ); print_r ($_SESSION ["SESS"]); reset ($_SESSION ["SESS"] ); $i = 0; while (list ($key, $val ) = each ($_SESSION ["SESS"] ) ) { echo $b; } ?> thank you ------------------------------------------------------------------------ [2003-06-16 08:27:33] sniper@php.net You're doing something wrong. (not enough info to be sure, but it works just fine here when you do it right..) ------------------------------------------------------------------------ [2003-06-16 05:51:38] admin at nexusfor dot com Description: ------------ When I read an array of objects saved in a session variable I cannot access object's variables. Print_r reports: Array ( [0] => __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => class_voucher_dettaglio [descrizione] => A3 [gg] => 1 [periodi] => 1 [base] => 23 [totale] => 23 ) This problem appears only when php retrieves variable from session_file (that appear correct) Reproduce code: --------------- while (list ($key, $val ) = each ($_SESSION ["PREV_DETTAGLIO"] ) ) { echo ($val->dettaglio); } Expected result: ---------------- list of values Actual result: -------------- nothing ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24202&edit=1

« previous php.bugs (#42040) next »