![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
ecshop浏览历史功能是怎么实现的,就是你浏览了某个商品就会写入cookie,是在哪里执行的呢
1个回答
展开全部
goods.php中
/* 记录浏览历史 */
if (!empty($_COOKIE['ECS']['history']))
{
$history = explode(',', $_COOKIE['ECS']['history']);
array_unshift($history, $goods_id);
$history = array_unique($history);
while (count($history) > $_CFG['history_number'])
{
array_pop($history);
}
setcookie('ECS[history]', implode(',', $history), gmtime() + 3600 * 24 * 30);
}
else
{
setcookie('ECS[history]', $goods_id, gmtime() + 3600 * 24 * 30);
}
/* 记录浏览历史 */
if (!empty($_COOKIE['ECS']['history']))
{
$history = explode(',', $_COOKIE['ECS']['history']);
array_unshift($history, $goods_id);
$history = array_unique($history);
while (count($history) > $_CFG['history_number'])
{
array_pop($history);
}
setcookie('ECS[history]', implode(',', $history), gmtime() + 3600 * 24 * 30);
}
else
{
setcookie('ECS[history]', $goods_id, gmtime() + 3600 * 24 * 30);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询