Cookies in multisite where network sites have their own domain name

I decided to integrate several stand alone WordPress websites into a single multisite installation.

I created a brand new multisite install with subdirectories, created a MU network site with subdirectory URL, and exported the content from the original standalone site, then imported that content into the subdirectory MU site.

I then removed the original standalone site from cPanel, and set the MU site’s domain name to the original domain name.

The site loads on its original domain name, but when I try to login to domainname.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.

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 subdirectory site, then delete the standalone site from cPanel, and then set the MU subdirectory site’s URL to be the original standalone site’s domain name. The site’s front end loads fine, I just can’t login to admin.

Help appreciated.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

First Clear Browser Cache (including cookies) + server cache from cache plugins etc.

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', 'your-domain.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 support, there may be a configuration issue in the server.

Method 2

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 blend of Scott’s fix:

Note: I didn’t do any cookie cache clearing

a) 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 )

b) 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.com.au');
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. */

Method 3

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.

Method 4

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.

Method 5

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.

Method 6

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', 'your-site.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.

Method 7

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.

Method 8

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.

Method 9

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);

Method 10

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

Method 11

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 ) );

Method 12

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.

Method 13

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' ] );


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x