// bir örnek yazdım geliştirmesi sana kalmış
<?php
function GetCurrentUri(){ return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";}
function GetLastVisited() {
return isset($_COOKIE['last_visited']) ? json_decode($_COOKIE['last_visited'],true) : [];
}
function UpdateVisited(){
$list = array();
if(isset($_COOKIE['last_visited'])){
$list = json_decode($_COOKIE['last_visited'],true);
}
if(($count = count($list)) > 0){
if($list[$count - 1] != GetCurrentUri()){
array_push($list ,GetCurrentUri());
}
}else{
array_push($list ,GetCurrentUri());
}
setcookie('last_visited', json_encode($list), time()+(60 * 60 * 24));
}
$list = GetLastVisited();
if(count($list) > 0){ // eğer geçmiş kayıtları varsada
echo "<h1>Son gezilen listesi </h1>";
echo "<ul>";
foreach($list as $key => $item){
echo "<li>".($key + 1) . " . " . $item."</li>";
}
echo "</ul>";
}
// sayfa sonunda güncelleme yaparsın
UpdateVisited();