foreverdita Posted October 9, 2009 Share Posted October 9, 2009 OK, this one is stumping me to no end. Zen cart storing in session arrays. One array, which I can access, is called the cart. I can see it by doing a print_r($_SESSION['cart']); The problem i am having is that within this cart array, there is another object called freeProduct. I want to ONLY access the freeProduct array WITHIN the cart array. The reason I want to do this is because I need to remove some of the session variables that are stored in this multidimensional array. I have been strugglnig with this for almost two hours now, to no avail. Can some genius help moi? Quote Link to comment https://forums.phpfreaks.com/topic/177128-need-major-help-from-a-php-session-guru/ Share on other sites More sharing options...
foreverdita Posted October 9, 2009 Author Share Posted October 9, 2009 Perhaps this will give more information: This is the print_r of the cart session. What I need to be able to do is clear out (unset) the session beneath the cart that is called freeProduct Object. [cart] => shoppingCart Object ( [contents] => Array ( [254:1b8a79c62ecfecf500c32bce6eb3d6a9] => Array ( [qty] => 1 [attributes] => Array ( [1] => 2 ) ) [412] => Array ( [qty] => 1 ) ) [total] => 3.25 [weight] => 4 [cartID] => 93181 [content_type] => physical [free_shipping_item] => 0 [free_shipping_weight] => 0 [free_shipping_price] => 0 [freeProductID] => 412 [observers] => Array ( [172b7d646c9d333e306482af66c329c0] => Array ( [obs] => freeProduct Object ( [freeAmount] => 1 [freeProductID] => 412 [observers] => Array ( ) ) [eventID] => NOTIFIER_CART_ADD_CART_END ) [4fb8d004a700b8316be4c1c3e4bb834c] => Array ( [obs] => freeProduct Object ( [freeAmount] => 1 [freeProductID] => 412 [observers] => Array ( ) ) In red is what I want to clear. Quote Link to comment https://forums.phpfreaks.com/topic/177128-need-major-help-from-a-php-session-guru/#findComment-933958 Share on other sites More sharing options...
xenophobia Posted October 10, 2009 Share Posted October 10, 2009 $_SESSION['cart'] is an object. You have to typecast it: $arry = (array) $_SESSION['cart']; from here, do whatever you want like an array. Quote Link to comment https://forums.phpfreaks.com/topic/177128-need-major-help-from-a-php-session-guru/#findComment-934211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.