$_COOKIE保存浏览记录失败
做商城的时候,想用$_COOKIE保存浏览商品的ID,但不知道怎么搞得,只能保存一条,有时候一条都保存不了,下面是我的代码
$count=count($_COOKIE['id']);
if(!isset($_COOKIE['id'])){
setcookie("id[]",$_GET['id'],time()+60*5);
}elseif(!in_array($_GET['id'],$_COOKIE['id'])){
setcookie("id[]",$_GET['id'],time()+60*5);
}
哪位懂的,能帮解决下吗
$count=count($_COOKIE['id']);
if(!isset($_COOKIE['id'])){
setcookie("id[]",$_GET['id'],time()+60*5);
}elseif(!in_array($_GET['id'],$_COOKIE['id'])){
setcookie("id[]",$_GET['id'],time()+60*5);
}
哪位懂的,能帮解决下吗
作者: 彭震 发布时间: 2011-07-13
id[]里面要给值的,你可以这样写:
$count=count($_COOKIE['id']);
if(!isset($_COOKIE['id'])){
setcookie("id[".$_GET['id']."]",$_GET['id'],time()+60*5);
}elseif(!in_array($_GET['id'],$_COOKIE['id'])){
setcookie("id[".$_GET['id']."]",$_GET['id'],time()+60*5);
}
$count=count($_COOKIE['id']);
if(!isset($_COOKIE['id'])){
setcookie("id[".$_GET['id']."]",$_GET['id'],time()+60*5);
}elseif(!in_array($_GET['id'],$_COOKIE['id'])){
setcookie("id[".$_GET['id']."]",$_GET['id'],time()+60*5);
}
作者: yancheng 发布时间: 2011-07-15