The core of the problem is that you set cookies when the content is being accessed, not when it is read. Browsers can try to prefetch content, and your description sound like the browser is prefecthing the “next” link found in the header.
From experience, you should avoid setting cookies on the server and prefer setting them on client side (add to the html a small JS that will set the cookie) or even better if possible, use local storage instead.
Related Posts:
- Passing current cookies in wp_remote_get to get Draft Post Preview
- How to mark articles as read?
- Querying post from a multisite network
- How to hide a post from ‘Recent Posts’ widget?
- How to get most recent commented post above new submitted post in WordPress?
- How to start with post number x?
- Display most recent post on homepage?
- Duplicate posts and change category
- recent posts for different categories
- WP Bakery Load More Button loads the same posts
- Multi row post list
- How to get date of post when using wp_get_recent_posts()?
- Latest posts by category — how to exclude current post?
- Add hero image to home page (blog format) via the dashboard
- Why aren’t paragraphs breaking on this page?
- Get x recent posts by author?
- Showing recent post of category in page
- How to show 3 most recent/viewed posts in a special tiles on home page using wordpress?
- Prevent duplicate pages from being added
- Google indexing duplicate page content with Page #### in post title and /page-2 in permalink instead of the ones I set
- SQL query: select duplicate posts – but using duplicate meta [duplicate]
- Have latest post and recent posts display differently
- Stop WordPress automatically adding tags to post content
- Front-End Post Submission
- Let private posts stay in status “private” after edit through “editors”
- how to get a different html for odd/even posts?
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- How do I create a link that will always show the latest post?
- How to display posts by current user/author in a custom page template?
- Display all search results
- featuring old articles without messing up with the archive
- Add default content to post (for specific category)
- Display most recent post in category instead of archive?
- Is there a plugin that creates a WP post based on a Twitter account’s hashtag?
- blog page showing only first post
- Human Time Diff, change mins to minutes
- Display the latest posts, published in the last hour, with WP_Query
- Including text at the end of every post
- same template for multiple custom post type single
- Allowing the SoundCloud player to appear in a post excerpt
- Display the Content of a Post with qTip2
- Scheduled posting not working
- Converting multiple loops into one single loop with pagination
- How to set post expiration date and time and move the page to archive after expiration [closed]
- .current-menu-item class on custom post type children pages – again?
- How to get only text from wordpress post content?
- I want to show category in the post title , how can I do
- I want to get title name of post, but i didn’t get by this code. Any suggestion?
- How to modify post content?
- Allow public to post on blog
- Facebook doesn’t display the related thumbail for some posts
- How to re-post an old post?
- Emojis replaced by ‘?’ automatically
- Creating a post from data returned from HTML form
- Using ajax on editing a category edit page?
- Do action on publish or update?
- Get Post’s first image using Short-code
- Delete post results in “Cannot delete or update a parent row: a foreign key constraint fails”
- Let both the admin and post author update comment meta
- Modify posts listing at back end
- WordPress Query Posts From Category Post on Static Page
- How to update all posts at once?
- How to allow multiple thumbnail upload for Posts?
- Loop through posts? Want to remove extra newlines in actual post HTML/content on backend
- Random posts that always include a particular post?
- How to remove text and retain in caption image using the_content function
- Show number of posts by logged in user
- How does WP decide how to display a page
- Cannot implement byline into posts container in single.php
- Insert data from custom created PHP page into wp_postmeta table
- Internal linking to posts permalink fail because of spaces and stripe at postname
- alternative to wp_link_pages() that only shows link to last page
- Link to older links
- WordPress Excerpt Paragraph Limiting
- display jumps to the bottom, dosnt start at the top?
- How to implement a WordPress comments function?
- How can I restore posts from ‘trash’ with their previous post_status? – WordPress
- Shortcode for Comments and Comment Boxes in Post Loop
- “Blog pages show at most” in setting not working
- My page shows some other content in WP
- Weird problem occurs while using WordPress REST API to create new post
- WordPress get tags in “publish_post” hook
- Dropdown Select Post Filter
- What permissions does a role need for the user to be assigned as the author of a post?
- Add postmeta to all blog posts
- Enable HTML Tags in WordPress Post excerpt
- Checking if a post contains an html tag
- If taxonomy has more than 6 posts, display show all
- How to give priority to page than to posts permalink structure?
- Add category information beneath post?
- Post are not showing up
- how to remove entry meta from wordpress archive category and change its display
- Save/retrieve form data best practises for theme development
- Changing permalink of custom category
- Special Query: Title, Terms, Content – %LIKE%
- Error establishing a database connection
- How to limit the number of posts a user can publish based on user type
- Add News Feed to bespoke website, only to one page on whole site
- How to display my categories in a list (to a post, not the sidebar)?
- Output number of WordPress posts remaining until a post milestone is reached