In a WordPress Multisite setup, administrators may encounter login failures on sub-sites, especially when the main site and sub-sites are on different domains. This guide aims to address this issue to ensure seamless access and login to sub-sites.
Problem Description
In a typical WordPress Multisite network, the main site and sub-sites may share the same top-level domain. However, there might be instances where completely different domains are used. For instance, the network structure might be as follows:
- example.com (Main site)
- sub.example.com (Sub-site)
- example.net (Sub-site)
In this structure, an error stating “Cookies are blocked or not supported by your browser” may arise when attempting to access or login to example.net
, even though this issue doesn’t occur when switching from example.com
to sub.example.com
.
Solution
- Update the
wp-config.php
File:
Add the following code in yourwp-config.php
file to ensure that cookies work correctly across different sub-domains:
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
This way, WordPress will set the appropriate cookies for your browser regardless of which site you are accessing.
- Clear Browser Cookies and Cache:
After making the changes, clear your browser’s cookies and cache, then try logging in again. - Use Plugins:
There are plugins like WP Multisite SSO that might help with single sign-on across different domains. Although we haven’t tried it personally, it might be an option to resolve this issue.
Understanding COOKIE_DOMAIN
The COOKIE_DOMAIN
constant tells WordPress how to set cookies. When you log in, WordPress sets a cookie in your browser to mark you as authenticated. The COOKIE_DOMAIN
sets the scope of this cookie, i.e., the browser will only send the cookie back to sites that match its scope. For example, if you log into example.com
, the scope of this cookie will be set to example.com
, and your browser will send this cookie only when you access this domain or its sub-domains.
Additional Resources
Through the steps outlined above, you should be able to resolve the sub-site login failure issue in a WordPress Multisite network, particularly when different domains are utilized.