I'm trying to store the contents of a shopping cart in a cookie... So I thought the best way would be to hold the product id and quantity in an array.
I'm serialiZing the array when I store it but when I try to access it at a later stage it's converting to a boolean, hence I can't access the darn thing.
Here's my code...
All seems to be well storing the cookie... When I'm trying to access the cookie with the following code...$basket[$product_id] = $qty;
$basket = serialize($basket);
setcookie("basket",$basket,time()+604800);
$basket = unserialize($basket);
echo gettype($basket); -----> Shows "array"
I'm getting the error: Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in...if(isset($_COOKIE[basket]))
{
$basket = unserialize($_COOKIE[basket]);
if(array_key_exists($product_id,$basket))
{
... more code
}
}
If I run a
Anyone any ideas??? Even if I type cast the booloan to an array it still won't work?echo gettype($basket); ------> Shows "boolean"??
TIA








Bookmarks