Sunday 15 August 2010

PHP session variable within other variable -



PHP session variable within other variable -

i have page (cart page in ecommerce) info id access via php can mail service it.

when print session variables using print_r( $_session ); next code.

i want echo value of "total".

i using $_session['cart']['total']; doesn't work.

all other outputs "currency" , "language" displayed should be.

what doing wrong here?

array(22) { ["sessiontoken"]=> &string(32) "2239f469b65f039885a0c747f6595609" ["cart"]=> &object(shoppingcart)#1 (5) { ["contents"]=> array(2) { [216]=> array(1) { ["qty"]=> int(1) } [71]=> array(1) { ["qty"]=> int(1) } } ["total"]=> float(115.9) ["weight"]=> float(0) ["cartid"]=> &string(5) "91586" ["content_type"]=> string(8) "physical" } ["language"]=> &string(7) "english" ["languages_id"]=> &string(1) "1" ["currency"]=> &string(3) "usd" ["navigation"]=> &object(navigationhistory)#2 (2) { ["path"]=> array(5) { [0]=> array(4) { ["page"]=> string(9) "index.php" ["mode"]=> string(6) "nonssl" ["get"]=> array(1) { ["cpath"]=> string(2) "50" } ["post"]=> array(0) { } } [1]=> array(4) { ["page"]=> string(7) "404.php" ["mode"]=> string(6) "nonssl" ["get"]=> array(0) { } ["post"]=> array(0) { } } [2]=> array(4) { ["page"]=> string(21) "checkout_shipping.php" ["mode"]=> string(3) "ssl" ["get"]=> array(0) { } ["post"]=> array(15) { ["formid"]=> string(32) "2239f469b65f039885a0c747f6595609" ["action"]=> string(7) "process" ["payment"]=> string(5) "gspay" ["shipping"]=> string(9) "flat_flat" ["hd_shipping"]=> string(5) "12.00" ["hd_std_shipping"]=> string(5) "29.00" ["cust_fname"]=> string(1) "k" ["cust_lname"]=> string(1) "k" ["cust_email"]=> string(10) "kk@kkk.xom" ["cust_street"]=> string(3) "kkk" ["cust_city"]=> string(3) "kkk" ["cust_state"]=> string(3) "kkk" ["cust_zip"]=> string(3) "222" ["country"]=> string(2) "72" ["btnsubmit"]=> string(20) "continue checkout" } } [3]=> array(4) { ["page"]=> string(20) "checkout_payment.php" ["mode"]=> string(3) "ssl" ["get"]=> array(0) { } ["post"]=> array(0) { } } [4]=> array(4) { ["page"]=> string(25) "checkout_confirmation.php" ["mode"]=> string(3) "ssl" ["get"]=> array(0) { } ["post"]=> array(2) { ["formid"]=> string(32) "2239f469b65f039885a0c747f6595609" ["payment"]=> string(5) "gspay" } } } ["snapshot"]=> array(0) { } } ["user_type"]=> &string(5) "guest" ["sendto"]=> &null ["cartid"]=> &string(5) "91586" ["payment"]=> &string(5) "gspay" ["comments"]=> &null ["shipping"]=> &array(3) { ["id"]=> string(9) "flat_flat" ["title"]=> string(53) "global priority shipping (it takes 5-7 business days)" ["cost"]=> string(5) "12.00" } ["cust_fname"]=> &string(1) "k" ["cust_lname"]=> &string(1) "k" ["cust_email"]=> &string(10) "kk@kkk.xom" ["cust_street"]=> &string(3) "kkk" ["cust_city"]=> &string(3) "kkk" ["cust_state"]=> &string(3) "kkk" ["cust_zip"]=> &string(3) "222" ["cust_country"]=> &string(2) "72" ["cust_country_title"]=> &string(7) "finland" ["billto"]=> &null }

cart object should

$_session['cart']->total;

or if total private or corresponding class doesn't have magic getter __get(); (or check class api public method name returns $this->total;):

$_session['cart']->gettotal();

php session

No comments:

Post a Comment