zoukankan      html  css  js  c++  java
  • 查看浏览记录(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);
                }
            }
  • 相关阅读:
    css
    css笔记
    css笔记
    echarts
    css笔记
    跨域
    JS案例
    html2canvas
    echarts
    echarts
  • 原文地址:https://www.cnblogs.com/yuwensong/p/3767591.html
Copyright © 2011-2022 走看看