How to implement browsing History with php
Editor to share with you how to achieve php browsing history, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
The specific implementation methods are as follows:
/ * * Commodity history browsing history * $data merchandise record information * / private function _ history ($data) {if (! $data | |! is_array ($data)) {return false;} / / determine whether there is a browsing history if ($this- > _ request- > getCookie ('history')) {$history = unserialize ($this- > _ request- > getCookie (' history')); array_unshift ($history, $data) / / add / * remove duplicate records * / $rows = array (); foreach ($history as $v) {if (in_array ($v, $rows)) {continue;} $rows [] = $v;} / * remove * / while (count ($rows) > 5) {array_pop ($rows) if the number of records exceeds 5 / / Pop-up} setcookie ('history',serialize ($rows), time () + 3600002402500));} else {$history = serialize (array ($data)); setcookie (' history',$history,time () + 360024030par);}} these are all the contents of the article "how to achieve browsing History in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!