Current location - Music Encyclopedia - Chinese History - How does php browse history?
How does php browse history?
/**

* commodity history browsing record

* $data commodity record information */private function _ history ($data)

{If (! $data ||! is_array($data))

{returns false.

}

//Determine whether there is a browsing record in the cookie class.

If ($ this->; _ request->; getCookie('history '))

{ $ history = unserialize($ this-& gt; _ request->; get cookie(' history '); array_unshift($history,$ data); //Add at the top of the browsing record

/* Eliminate duplicate records */

$ rows = array(); Foreach($ history is $v)

{ if(in_array($v,$rows))

{Continue;

} $ rows[]= $ v;

}

/* If the number of records exceeds 5, delete */

while(count($rows)>5)

{ array _ pop($ rows); //popup}

setcookie('history ',serialize($rows),time() + 3600 * 24 * 30,'/');

} Otherwise,

{ $ history = serialize(array($ data));

setcookie('history ',$history,time() + 3600 * 24 * 30,'/');

}

}