How to: Fix “Cookie check failure” or “Cookie nonce invalid”

This article is imperfect and will be enhanced over time, based on your issues and experiences. Don’t hesitate to leave comments at the article to let me know how you fixed your issue exactly, or the other issues you might have. Thanks 🙂

If you are using a plugin that is performing asynchronous queries (ajax requests), it needs to use cookies to authenticate those, in order to make sure it’s you, and not someone nasty ill-minded.

Recently, a lot of errors seem to have been happening after an update of WP Rocket (at the end of 2022, I believe). If you are using it, then you probably find the cause.

How does this work

Those cookies are set/send via the nonce feature of WordPress: Cookie Authentification in WordPress REST API.

If you are using a caching plugin, those cookies are often cached. They have a lifetime of 12 hours, but depending on how the caching plugin works, it might be used right before expiration, or after, which will end in an cookie-related error. With a plugin that runs a process for a long time with many asynchronous requests (such as Media Cleaner, for instance), the chance of getting an error is also much higher.

How to fix it?

How to fix this? Simple! Disable the caching plugin for the time of the process! If you would like to keep the caching plugin enabled, you can check the FAQ related to it, the answer should be there.

Here are links to the FAQ of a few caching plugins:

The issues seem to come from other plugins and systems as well. For example:

  • Comodo (Application Firewall)
  • The mod_security set by your hosting services

Let us know in the comments!

What is your hosting service? I know GoDaddy easily gets this issue (it’s not a good hosting service by the way, check my recommendations). Did you resolve it or not?