glenelkins Posted August 26, 2009 Share Posted August 26, 2009 does anyone know what this session string breaks down into? i cant find anything online that explains how they are put together cart|a:1:{i:0;a:3:{s:10:"product_id";s:1:"1";s:20:"product_price_number";s:1:"0";s:16:"product_quantity";s:1:"1";}} Quote Link to comment https://forums.phpfreaks.com/topic/172014-carta1i0a3s10product_ids11s20product_price_numbers10/ Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 this is a serialized string of an array use unserialize to re-create the array Quote Link to comment https://forums.phpfreaks.com/topic/172014-carta1i0a3s10product_ids11s20product_price_numbers10/#findComment-907007 Share on other sites More sharing options...
oni-kun Posted August 26, 2009 Share Posted August 26, 2009 They are serialized, to be placed into a database. The numbers generally depict the length of each string's variable.. You'd have to use unserialize to view it in an array or whatever it was stored in. Quote Link to comment https://forums.phpfreaks.com/topic/172014-carta1i0a3s10product_ids11s20product_price_numbers10/#findComment-907009 Share on other sites More sharing options...
glenelkins Posted August 26, 2009 Author Share Posted August 26, 2009 awsome Quote Link to comment https://forums.phpfreaks.com/topic/172014-carta1i0a3s10product_ids11s20product_price_numbers10/#findComment-907028 Share on other sites More sharing options...
glenelkins Posted August 27, 2009 Author Share Posted August 27, 2009 further to this, i tried the "unserialize" function on the following session string cart|a:1:{s:5:"items";a:1:{i:0;a:3:{s:10:"product_id";s:1:"2";s:20:"product_price_number";s:1:"0";s:16:"product_quantity";s:1:"1";}}}theme|s:7:"default";order|a:19:{s:9:"firstName";s:0:"";s:8:"lastName";s:0:"";s:11:"companyName";s:0:"";s:5:"email";s:0:"";s:9:"telephone";s:0:"";s:6:"mobile";s:0:"";s:26:"deliveryBuildingNumberName";s:0:"";s:18:"deliveryStreetName";s:0:"";s:16:"deliveryTownCity";s:0:"";s:21:"deliveryStateProvince";s:0:"";s:15:"deliveryCountry";s:0:"";s:21:"deliveryZipPostalCode";s:0:"";s:25:"billingBuildingNumberName";s:0:"";s:17:"billingStreetName";s:0:"";s:15:"billingTownCity";s:0:"";s:20:"billingStateProvince";s:0:"";s:14:"billingCountry";s:0:"";s:20:"billingZipPostalCode";s:0:"";s:10:"formAction";s:11:"reviewOrder";} And i get this error: Notice: unserialize() [function.unserialize]: Error at offset 0 of 744 bytes in C:\xampp\htdocs\Framework\Modules\admin\Models\ordersModel.php on line 24 Quote Link to comment https://forums.phpfreaks.com/topic/172014-carta1i0a3s10product_ids11s20product_price_numbers10/#findComment-907569 Share on other sites More sharing options...
JonnoTheDev Posted August 27, 2009 Share Posted August 27, 2009 This is oscommerce isn't it. The serialized session contains an object of cart. The session handler will unserialize it. Why are you attempting to do this yourself. Quote Link to comment https://forums.phpfreaks.com/topic/172014-carta1i0a3s10product_ids11s20product_price_numbers10/#findComment-907573 Share on other sites More sharing options...
glenelkins Posted August 27, 2009 Author Share Posted August 27, 2009 no this is not oscommerce its a custom application. because the users shopping cart is stored in my sessions which i also then make a copy of the serialized string into the orders table...to make it easier to manage rather than typing more insert quieries, i just want to be able to decode the string to get the values that WERE in the session Quote Link to comment https://forums.phpfreaks.com/topic/172014-carta1i0a3s10product_ids11s20product_price_numbers10/#findComment-907582 Share on other sites More sharing options...
glenelkins Posted August 27, 2009 Author Share Posted August 27, 2009 its ok i forgot to serialize the session generated string before using it in the database Quote Link to comment https://forums.phpfreaks.com/topic/172014-carta1i0a3s10product_ids11s20product_price_numbers10/#findComment-907584 Share on other sites More sharing options...
alexdemers Posted August 27, 2009 Share Posted August 27, 2009 obviously "cart|" should not be part of the unserialization. This was probably for reference so: $serial = substr($_COOKIE['name_of_cookie'], 5); $array = unserialize($serial); Quote Link to comment https://forums.phpfreaks.com/topic/172014-carta1i0a3s10product_ids11s20product_price_numbers10/#findComment-907593 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.