How to fix WordPress cookie error

You want to log into your WordPress backend as usual and nothing happens. Instead of being redirected to the backend, you only get a bright red error message that describes that your backend is blocked because of so-called cookies – the WordPress cookie error. We’ll show you what you can do to get back to your backend!

After logging in, your WordPress site greets you with the message “ERROR: Cookies are blocked due to an unexpected output…”. A login is no longer possible, the WordPress cookie error. This error is currently very common on any WordPress site and causes some operators stomach ache:

What are cookies?

Many only know so-called cookies from the annoying messages that are mandatory on every website, but what is behind it?

A cookie is a piece of text information that websites place on your computer via the browser you are using (e.g. Chrome). Your computer sends back the information stored in the cookie each time you visit the site again – this way the site receives certain information about you. You have probably already noticed that after you have searched for a WordPress book on Amazon, for example, you see advertisements for books on Amazon on many of the pages you visit as a result. The cookie stored on your computer has therefore remembered what you were looking for and passes on this information. This is completely normal and happens every day.

How do I fix the WordPress cookie error?

Attention: In this guide we will show you possible solutions that describe changes in the code. You should only do this if you know what you are doing. If you need help, we are happy to be there for you by email (support@support-camp.io) or in the comments 🙂

As is so often the case in the WordPress world, there are various causes here as well. First of all, we recommend that you delete your browser’s cookies. Depending on the browser, this works a little differently, googling is best here. “Delete browser + cookies” is the request (replace browser with your browser, e.g. Chrome 😉 ). If the WordPress cookie error persists, we have to go deeper into the system.

Check your wp-config.php for errors:

Use your FTP program to navigate to the folder in which your WordPress installation is located and download the “wp-config.php” file. You can open the file with any text editor. Now check the file for the following errors:

  • Are there spaces or weird strings at the beginning or end of the file?
  • Is the correct domain set after the points “WP_HOME” and “WP_SITEURL”?
  • Caching plugins (WP Cache, W3 Total Cache) often replace the cookie domain (COOKIE_DOMAIN in the file) – check whether the correct domain is stored
  • Save the wp-config.php in a text editor in UTF-8 format without BOM.

Usually there are problems from point 1 – i.e. spaces at the beginning or end of the file that lead to the error.

Permanently fix the WordPress cookie error:

If the above solutions do not work, there is another way from the WordPress forum to fix the WordPress cookie error:

  1. Open the functions.php file in your WordPress folder
  2. Add the following code to the end of functions.php and save the file to your server again via FTP:
setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
if ( SITECOOKIEPATH != COOKIEPATH ) setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);

This method should fix the cookie error permanently.

If you continue to have problems logging in, check out our other login redirect post. If none of the above solutions work, we will be happy to help you in our personal support. Simply send an email with your problem description to support@support-camp.io or leave a comment 🙂

Other problems? More WordPress help: