‘ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.’

I recently struggled when I tried to add a new website to my WordPress multi-site installation. When I was using a subdomain (newsite.parentsite.com) everything was working fine, but as soon as I moved the new site to its own domain (owndomain.com) I couldn’t log in and I was stuck in a loop with the following error appearing: ” ‘ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.’”
This was quite frustrating and I wasted way too much time trying to solve it. Luckily I came across the following forum post that details a solution: https://wordpress.org/support/topic/changes-domain-and-now-i-get-cookie-error/ .

In essence you do the following:

  1. Under your /wp-content/ folder create a /mu-plugins/ folder if one doesn’t exist already. This stands for “must use” and contains plugins that WordPress must load for all sites.
  2. Create a new file (fix_cookies.php) in the mu-plugins directory.
  3. Paste the following code in the fix_cookies.php file:
<?php
add_action( 'muplugins_loaded', function(){
	global $current_blog, $current_site;
	if ( false === stripos( $current_blog->domain, $current_site->cookie_domain ) ) {
		$current_site->cookie_domain = $current_blog->domain;
	}
});

That’s it. After a refresh you should be able to login to your dashboard.

Leave a Reply

Your email address will not be published. Required fields are marked *