21

I decided to integrate several standalone WordPress websites into a single Multisite installation.

I created a brand new Multisite install with subdomains, created a MU network site with subdomain URL, and exported the content from the original standalone site, then imported that content into the subdomain MU site. I then deleted the original standalone site from cPanel, and set the MU site's domain name to the original domain name.

The main site loads fine now on its original domain name, but when I try to login to the subdomain site at site.example.com/wp-admin/ (using the brand new multisite's network admin user credentials), I receive an error:

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

But cookies are enabled in Chrome.

I tried adding the following to wp-config.php:

define('COOKIE_DOMAIN', false);

...but the issue remains.

The same issue occurs if I use WP Migrate DB Pro to pull in a standalone website into a MU subdomain site, then delete the standalone site from cPanel, and then set the MU subdomain site's domain to be the original standalone site's domain name... the site's frontend loads fine, but I just can't login to WP admin.

7
  • 1
    Have you seen this answer How to set up Wordpress Multisite on multiple domains without plugin?
    – bueltge
    Commented Mar 16, 2017 at 13:41
  • Thanks @bueltge, tried adding define('COOKIE_DOMAIN', false); but logging into a sub-site with its own domain doesn't work - it loops back to the same login screen.
    – Steve
    Commented Mar 17, 2017 at 18:23
  • @Steve you should attempt specifically what the answer states and set it to an empty string, i.e. define('COOKIE_DOMAIN', '');. Boolean false may or may not have the same meaning as an empty string '', depending on the application.
    – bosco
    Commented Mar 21, 2017 at 23:42
  • By MU, do you mean you are using a domain mapping plugin? Thanks.
    – Greeso
    Commented Mar 23, 2017 at 4:25
  • No @Greeso, using the built in site URL functionality.
    – Steve
    Commented Mar 23, 2017 at 5:22

15 Answers 15

38
+50

First clear your browser's cache (including cookies), and your server's cache (e.g. cache plugins). Then set the following in your wp-config.php file:

define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');

Also, you may checkout the answer from HERE:

define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('SUNRISE', 'on');

If it still fails, then read this answer or contact your server's support. There may be a configuration issue on the server.

4
  • Hi Scott. A similar issue has arisen on another MU site. I've added the constants above to wp-config.php, but on this other MU site, childsitedomain.com/wp-login.php produces the error The constant "COOKIE_DOMAIN" is defined (probably in wp-config.php). Please remove or comment out that define() line. Any ideas on how to tackle this situation?
    – Steve
    Commented Mar 27, 2017 at 10:53
  • If I comment out that statement, I receive the error after logging into the child site: ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.
    – Steve
    Commented Mar 27, 2017 at 10:56
  • I've raised this issue in a new question.
    – Steve
    Commented Mar 27, 2017 at 11:03
  • 1
    the 4 lines on the top section did it for me
    – azote
    Commented Jul 21, 2022 at 15:40
9

Using WordPress version 4.9.4.

I was getting the cookie error and looked through various help options and eventually solved it by using a parts of Scott's fix. (Note: I didn't do any cookie cache clearing.)

  1. Editing out sunrise.php line in wp-config.php (I was using native domain mapping so removed the MU plugin install changes that I'd made )

  2. Adjusted my wp-config.php to

    /* Multisite */
    
    define('WP_DEBUG', false);
    
    define( 'WP_ALLOW_MULTISITE', true );
    
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    define('DOMAIN_CURRENT_SITE', 'www.mysite.example');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
    /* define( ‘COOKIE_DOMAIN’, $_SERVER[ ‘HTTP_HOST’ ] ); */
    
    define('ADMIN_COOKIE_PATH', '/');
    define('COOKIE_DOMAIN', '');
    define('COOKIEPATH', '');
    define('SITECOOKIEPATH', '');
    
    /* That's all, stop editing! Happy blogging. */
    
4

Finally after hours, literally, of troubleshooting I was able to get this resolved on the AWS Lightsail Bitnami Multisite Wordpress (WordPress 5.0.4) instance by performing the following:

  1. Ensure the WPMU Domain Mapping plugin is disabled
  2. Edit /opt/bitnami/apps/wordpress/htdocs/wp-config.php...

    a. Add the following:

     define('ADMIN_COOKIE_PATH', '/');
     define('COOKIE_DOMAIN', '');
     define('COOKIEPATH', '');
     define('SITECOOKIEPATH', '');
    
     /* That's all, stop editing! Happy blogging. */
    

    b. Comment out:

    // define('SUNRISE', 'on');
    

After these changes, login was successful - no errors. Thanks for everyone's input. If it was not for that, I would still be scratching my head.

I did find the answer here:

https://docs.bitnami.com/aws/apps/wordpress-multisite/configuration/configure-wordpress-multisite

This domain mapping functionality is included in WordPress Multisite since v4.5. If you’re using an older version, you will need the WordPress MU Domain Mapping plugin.

So it appears that the WPMU Domain Mapping plugin is unnecessarily included in the AWS Lightsail Bitnami Multisite package.

1
  • Thanks for this! It worked for me without disabling WPMU Domain Mapping plugin. I also did not find SUNRISE anywhere, so I didn't have to comment that out either. Commented Aug 19, 2019 at 22:08
2

I just finished troubleshooting a similar issue with subdomain multisite.

With:

define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);

The site was still throwing a cookie error and in some instances of trying what was suggested above.........

define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', ''); 

This caused a different error to delete defines referencing "COOKIE_DOMAIN" upon visiting subsites.

Finally I was able to login after making sure both of these were defined just above the multisite network information

define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
define('COOKIE_DOMAIN', '');

Try making sure these are both defined. I hope this helps.

2
  • To clarify above, it seems to work with just define('COOKIE_DOMAIN', ''); Commented Dec 6, 2017 at 17:22
  • It works, but it breaks the post preview... I get: Sorry, you are not allowed to preview drafts. Commented Jan 7, 2021 at 13:36
1

I commented out define('SUNRISE', 'on');

/* define('SUNRISE', 'on'); */
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
define('COOKIE_DOMAIN', '');

Then, I don't see the below error message:

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

Login also started working.

1
  • One can skip the 2nd line as well, which is effectively being overridden by the 3rd. :)
    – jgangso
    Commented Aug 17, 2022 at 8:27
1

So I was having this issue as well and came across a lot of solutions like the ones mentioned here but they didn't work.

What did work was simply adding the following to the multisite configuration in wp-config:

define('COOKIE_DOMAIN', false);

so that the section in wp-config looks like so:

define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('COOKIE_DOMAIN', false);

posting here so that others may find it and spend less time banging their head against their desk than I did.

1

Don't know about you folks, but for me it helped surprisingly much to change this

define( 'COOKIEDOMAIN', '' );

to this

define( 'COOKIE_DOMAIN', '' );

And yes, I still dare to consider myself an experienced PHP & WP developer. Just wanted to share that it happens to all of us. :)

0
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
//define('DOMAIN_CURRENT_SITE', 'masterdigitalservices.com');
//define('PATH_CURRENT_SITE', '/');
//define('SITE_ID_CURRENT_SITE', 1);
//define('BLOG_ID_CURRENT_SITE', 1);

Here's my new wp-config. Looks like it got hardcoded to be a specific site, and wasn't letting other domains work -- only subdomains. Great answers here.

0

I was having this issue as well, and nothing I did helped. Tried it in Microsoft Edge, and didn't get the error.

So in my case at least, it was just Google Chrome causing the problem.

0

Strangely it worked for me (on more than one multisites) to set SUBDOMAIN_INSTALL to false. To be honest, I hadn't had time to investigate further why ...

define('SUBDOMAIN_INSTALL', false);

0

THIS FIXED IT FOR ME I had not setup WordPress fully for the new domain name. I had created my site subdomain.domain.com I then wanted to remain as newdomain.com over subdomain.domain.com This required

  1. WordPress network > admin > site, change site to new name (which I had already done, site was working)
  2. WordPress network > admin > settings > domains, add in new name to site ID and tick yes for primary domain (to indicate this name is the primary name). To find site ID, you can hover over the network > admin > site which will say which site ID you are working on. Hope this helps anyone who was getting the cookies are blocked or not supported message when trying to login Best wishes SamTapsell
0

I was able to resolve the issue after adding the below in wp-config.php. Reference

define( 'COOKIEPATH', preg_replace( '|https?://[^/]+|i', '', get_option( 'home' ) . '/' ) );
define( 'SITECOOKIEPATH', preg_replace( '|https?://[^/]+|i', '', get_option( 'siteurl' ) . '/' ) );
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
define( 'PLUGINS_COOKIE_PATH', preg_replace( '|https?://[^/]+|i', '', WP_PLUGIN_URL ) );
0

I solved the problem with this:

Change the setting of DOMAIN_CURRENT_SITE in wp-config.php to:

 define('DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST']);

So my setup is this:

define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST']);
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Then I could login to all multisite website on url e.g. web1.example.com/wp-admin or web2.example.com/wp-admin.

0

This is what we are using on SlickStack for Multisite installations... it works for both subdomain networks and/or custom domain names as well:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST']);
define('NOBLOGREDIRECT', 'https://example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

And then:

define('COOKIE_DOMAIN', false);
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');
define('ADMIN_COOKIE_PATH', '/');
-1

Please try adding the following to your wp-config.php file

Also remove all cookies from your browser before testing

define( 'COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] );
1
  • When I made that change, I couldn't log into any website, including the main website.
    – Steve
    Commented Mar 17, 2017 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.