Zend会话问题

时间:2011-08-11 05:40:30

标签: zend-framework session namespaces cart shopping

在尝试制作简单的购物车时,Zend会话遇到一个小问题

我有以下代码来设置会话变量:

# $qty = quantity selected by user
# $itemid = product itemid

$ShoppingCart = new Zend_Session_Namespace('ShoppingCart');

$ShoppingCart->active = '1';

if($qty != $ShoppingCart->$itemid){
   $ShoppingCart->$itemid = $qty; 
}

现在,如果我这样做:

print_r($_SESSION)

我得到了,例如:

Array ( [ShoppingCart] => Array ( [active] => 1 [22] => 3 [24] => 1 ) ) 

但是,如果我尝试循环遍历Zend Session数据,如下所示:

foreach($ShoppingCart as $sckey => $value){
   print "CART - $sckey = $value<br>";          
}

我明白了:

CART - active = 1
CART - 0 = 3
CART - 1 = 1

有谁知道为什么我没有得到正确的itemid作为键?

0 个答案:

没有答案