<?
$price_id = $_GET['price_id'];
$price_id=(int)$price_id;
$output = array();
$data = !empty($_COOKIE['products']) ? unserialize($_COOKIE['products']) : array();
if ($price_id)
{
$key=array_search($price_id,$data);
if($key)
unset($data[$key]);
else
{$data[]=$price_id;};
}
print_r($data);
setcookie('products', serialize($data), time() + 172800, "/", '', false, true);
$output['products'] = array($data);
echo json_encode($output);?>
|