控制面板 - 帮助中心 - 付款方式 - 常用文档 - 软件下载 -   
服务中心
当前位置:首页 - 服务中心 - 网络学院

PHP实现浏览历史记录

  很多网站均有这样的功能,特别是一些购物网站均设计有浏览历史这样一个特色的功能,当然了实现的方法是多种多样的。asp、php、jsp等等均可以实现。下面我们以PHP为例来演示一下。源代码为ecshop里面的一段,算是比较经典的写法。

  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);
}

更新时间:2010-5-19

7*24小时咨询热线:400-628-6536 0371-86013552 19937165195
传真:0371-86013552-6612 服务邮箱:web@3a88.com 代理邮箱:agent@3a88.com 备案邮箱:beian@3a88.com
运营商:郑州金飞科技有限公司 工商营业执照号:9141010567945717XL
公司地址:郑州高新技术产业开发区木兰里9号1号楼1单元14层310号 邮政编码:450000 豫ICP备12025635号-1 豫公网安备 41010502003077号