Unserialize error when displaying browsing history with a cookie
PHP Code
'; Echo '
Next page '; if (Isset ($_cookie[' his ")) { //echo $_cookie[' his '];exit; $data = unserialize ($_cookie[' his '); $url = $_server[' Request_uri '); $data [] = $url; $data = Array_unique ($data); if (count ($data) >10) { array_shift ($data); } $urls = serialize ($data); Setcookie (' His ', $urls, Time () *2*24*3600);} else { $url = $_server[' Request_uri '); $data [] = $url; $urls = serialize ($data); Setcookie (' His ', $urls, Time () *2*24*3600);}? >
After opening in the browser and entering an ID on the address bar, the browser gives a hint
HTML Code
Notice:unserialize () [function.unserialize]: Error at offset 9 of the bytes in D:\server\apache\www\20120413\history.php o N Line 16
And show the history of one, I think it may be related to the above error, can not find a solution, grammar I saw a few pieces, temporarily did not find the above error, looking for the!!!!!!
------Solution--------------------
$data = Unserialize (stripslashes ($_cookie[' his '));
So try, not to print out the cookie value to be affixed,