TP5 记录搜索历史

        $keyword = $this->request->param('keyword');
        if(cookie('keyword')){
            $history = explode(',',cookie('keyword'));
            
            array_unshift($history,$keyword);
            $history = array_unique($history);
            cookie('keyword',implode(',',$history),3600);
        }else{
            cookie('keyword',$keyword,3600);
          
        }
        if (!empty(cookie('keyword') )) {
            
            $histroy = explode(',', cookie('keyword') );
             
            foreach ($histroy as $key => $val) {
                $histroy_list[$key]['history'] = $val;
            }
          
        }
       

猜你喜欢

转载自www.cnblogs.com/aln0825/p/12213621.html
tp5
今日推荐