function save_history($id,$max=10)
{
$t = 60 * 60 * 24 * 365;
if ($_COOKIE['history_goods'])
{
$history_goods_arr = json_decode($_COOKIE['history_goods'],true);
if (in_array($id,$history_goods_arr))
{
return false;
}
if (count($history_goods_arr) >= $max)
{
array_shift($history_goods_arr);
}
$history_goods_arr[] = $id;
setcookie("history_goods",'',time()-3600);
setcookie("history_goods",$history_goods,time()+$t);
} else {
$history_goods_arr[] = $id;
$history_goods = json_encode($history_goods_arr);
setcookie("history_goods",$history_goods,time()+$t);
}
}