$cripts Posted April 5, 2007 Share Posted April 5, 2007 Ok for some reason this cookie wont keep the array values and it will simply reset to only on value in the array $shopitems = (isset($_COOKIE['shop_items'])) ? unserialize($_COOKIE['shop_items']) : array(); if(!$_GET['itemid'] || !is_numeric($_GET['itemid'])) { } else { $itemid = $_GET['itemid']; $shopitems[$itemid] = $itemid.',1'; setcookie('shop_items',serialize($shopitems),0,'',''); } wut this should do is when there is an itemid it will put it in the array of shopitems serialize it and set the cookie for later use the problem is that when there is allready an array serialized in the cookie it will not take that array values so instead of saying there is allready a value in the array of shopitems[2] and i want to add shopitems[4] it will simply use shopitems[4] to set the array And i tested it out on this which does the same thing and it works perfetcly fine.... $forum_review = (isset($HTTP_COOKIE_VARS['forum_view'])) ? unserialize($HTTP_COOKIE_VARS['forum_view']) : array(); $start = (!$_GET['start']) ? '0' : $_GET['start']; $enter = $start + 10; while($start < $enter) { $forum_review[$start] = '2'; setcookie('forum_view',serialize($forum_review),0,'',''); $start++; } Quote Link to comment Share on other sites More sharing options...
$cripts Posted April 5, 2007 Author Share Posted April 5, 2007 anyone got some ideas? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 5, 2007 Share Posted April 5, 2007 Try using stripslashes() before the unserialize: <?php $shopitems = (isset($_COOKIE['shop_items'])) ? unserialize(stripslashes($_COOKIE['shop_items'])) : array(); ?> Ken Quote Link to comment Share on other sites More sharing options...
$cripts Posted April 5, 2007 Author Share Posted April 5, 2007 ty Quote Link to comment 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.