PHP browsing History method, PHP browsing history
The example in this article describes how PHP browsing history is used. Share to everyone for your reference. The implementation method is as follows:
/** * Product History Browsing History * $data product record information */private function _history ($data) { if (! $data | |!is_array ($DATA)) { return FAL SE; } Determine if the cookie class has a browse record if ($this->_request->getcookie (' History ')) { $history = unserialize ($this- >_request->getcookie (' history ')); Array_unshift ($history, $data); Add/* To remove duplicate records at the top of the browsing record * /$rows = Array (); foreach ($history as $v) { if (In_array ($v, $rows)) { continue; } $rows [] = $v; } /* If the number of records extra 5 is removed */while (count ($rows) > 5) { array_pop ($rows);//Popup } Setcookie (' History ', serialize ($rows), Time () +3600*24*30, '/'); } else { $history = serialize (Array ($data)); Setcookie (' History ', $history, Time () +3600*24*30, '/');} }
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/965563.html www.bkjia.com true http://www.bkjia.com/PHPjc/965563.html techarticle PHP Browsing History method, PHP browsing history This article describes the PHP browsing history method. Share to everyone for your reference. The specific implementation method is as follows:/** * Products ...