I am using WordPress multisite setup to set the following structure
example.com
sub1.examples.com
example.net
Note that this is a single multisite setup, but it has two main domains and a subdomain.
I followed the steps described here to perform the setup.
Then, after adding example.net
to the sites list, I tried to go to its dashboard in the admin section. Once I did that, I was presented with a login screen. When I try to login, I receive the following error
ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.
After further investigation, I found this answer, which suggests adding define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
to wp-config.php. I did that, and now things worked. I was able to login to the site example.net
, but with a caveat.
The new problem is described as follows. Assuming I am in the WordPress backend, logged in to example.com
, and I try to go to example.net
. Once I do, I am presented with the login screen again to login to example.net
. I would not get that login screen if I go to sub1.example.com
from example.com
.
I have the following questions:
Why is this happening? In other words, why am I presented with a new login screen every time I try to switch between
example.com
andexample.net
?How can I prevent this from happeneing? I does not seem right. It looks like this is not a good solution to the problem. There might be another better way to fix this login issue.
What does
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
actually do?
Thanks.