You can mess around with two cookies (if there are really a lot of pages and users actually browse a lot and need tight control)
user_unique_id = user_unique_id уникальное_значение (token)visited_post_id = id
The first cookie we generate a unique user ID (any super unique). In the visited_post_id write the unique ID of the post (or page). The user enters, js checks cookies, if there are such cookies with these keys, then send them via ajax (json) to the server and check in the mysql table if there is a user with an identifier visited_post_id in the visited table whose visited_post_id is id . That is, it turns out if you arrange the control, then save it either in the user's browser or in the database.
In fact, even if you simply store the views in cookies (in the browser), then they will fit quite a lot. If you are moving in the direction of reducing the load on the server, then it makes sense to consider the option of transferring the “scanned messages” to the client.
But if you need tight control, then a unique identifier + session + cookie + save ip in mysql. Something like this. To begin with, in any case, it will be nice to generate a unique id for the user (if there is no such one yet). Here you can see how to set cookies on jQuery.
Below is the code to create a random token for the user.
function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min)) + min; } var d = new Date(); var n = d.getTime(); var token=n+getRandomInt(9,99999)+getRandomInt(1,99999);