脚本宝典收集整理的这篇文章主要介绍了php浏览历史记录的方法,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
本文实例讲述了PHP浏览历史记录的方法。分享给大家供大家参考。具体实现方法如下:
_request->getCookie('history')) { $history = unserialize($this->_request->getCookie('history')); array_unshift($history,$data); //在浏览记录顶部加入 /* 去除重复记录 */ $rows = array(); foreach ($history as $v) { if(in_array($v,$rows)) { continue; } $rows[] = $v; } /* 如果记录数量多余5则去除 */ while (count($rows) > 5) { array_pop($rows); //弹出 } setcookie('history',serialize($rows),time()+3600*24*30,'/'); } else { $history = serialize(array($data)); setcookie('history',$history,'/'); } }
以上是脚本宝典为你收集整理的php浏览历史记录的方法全部内容,希望文章能够帮你解决php浏览历史记录的方法所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。