查看浏览记录(thinkphp)
if ((MODULE_NAME == 'Goods' || MODULE_NAME == 'News') && ACTION_NAME == 'info' && $this->_get('id')) { $id = $this->_get('id'); $this->addHit(MODULE_NAME, $id); if (MODULE_NAME == 'Goods') { $recent_view = cookie('recent_view'); $recent_view = $recent_view ? unserialize($recent_view) : array(); $goods_info = M('Goods')->field('id, price, title, image')->find($id); $recent_view_key = array_search($goods_info, $recent_view); if ($recent_view_key !== false){ unset($recent_view[$recent_view_key]); } array_unshift($recent_view, $goods_info); if (count($recent_view) > 5) { array_pop($recent_view); } cookie('recent_view', serialize($recent_view), 3600 * 24 * 30 * 12); } }