So i need to create a cookie with the post IDs that the user has accessed(i have a WP site with 144 movie posts), and after to display these IDs on another page. I writed this code, but the problem is that when i try to print_r($_COOKIE);
in the history.php page i just get the ID of the current page=)) and not the movie posts IDs that the user has viewed in the past. So i want in this history.php page to display the history search of a user(the movies that he viewed on my site).
My script:
jQuery(document).ready(function($) {
let post_id = my_script_vars.postID;
document.cookie = 'Movie='+post_id+'; expires=Wed, 1 Jan 2070 13:47:11 UTC; path=/'
});