Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement browsing History with php

Shulou Source: shulou.com Published: 2022-06-03 19:46:59 11月12日 Update

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!

Tags: Browse History articles content goods not much Information most quantity method more knowledge Industry Information Information Channel Top Channel reference Learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Xiaomi vpn MariaDB Apple