Here is some code that you can put in the /wp-content/themes/yourtheme/header.php at the top. No doubt someone could code this as a WordPress plugin, but I don’t know how to do this! Another alternative would be to use PHP sessions instead of cookies.
<?php
function updatePagesVisited()
{
global $wp_query;
$post=$wp_query->get_queried_object();
$current_page_title=$post->post_title;
$days_to_store_cookie = 60;
$cookie_expiry_time = time() + $days_to_store_cookie*24*60*60;
if(isset($_COOKIE['pages_visited']))
{
$pages_visited=$_COOKIE['pages_visited'];
if(strlen($pages_visited)<1000)
{
if($current_page_title!=""&&$current_page_title!="index.php")
{
setcookie('pages_visited',$pages_visited.", ".$current_page_title,$cookie_expiry_time,"/");
}
}
}
else
{
setcookie('pages_visited',$current_page_title,$cookie_expiry_time,"/");
}
}
updatePagesVisited();
?>
Then in your templates you would need:
<?php echo $_COOKIE['pages_visited']; ?>
wherever you want to display the pages visited. You can change the strlen<1000 if you want to keep the list to display on one line.