dasha862,
как вариант ...
$(document).ready(function() {
var pageid = {%$page%};
var view = $.cookie('lastpage');
if (!view) {
view = [+pageid];
} else {
view = JSON.parse(view);
if (view.indexOf(+pageid) === -1) {
view.push(+pageid);
if (view.length > 10) view.shift();
}
}
view = JSON.stringify(view);
$.cookie('lastpage', view, {
expires: 60,
path: '/'
});
});