WordPress’ COOKIE_DOMAIN and Multisite with Domain Mapping

I have been managing a site with multisite and domain mapping, without the traditional plugin. Domain mapping is when you allow a multsite website like mysite.example.com to be used as the website for a different domain, like mysite.com.

The biggest problem I had was getting the admin login working on a mapped domain. This good tutoral explains how to fix that problem.

HOWTO Domain Mapping Without a Plugin

Another common fix is:

define('COOKIE_DOMAIN', false);
// in wp-config.php

What’s going on here? In the tutorial, you set the COOKIE_DOMAIN to the HTTP_HOST value. In this common fix, you eliminate the domain entirely. The issue is that the site sets the cookie’s domain value to the site’s domain, not to the mapped domain.

When you set it to the HTTP_HOST, you’re reflecting back the value that the client used to access the site.

When you set it to false, you eliminate that argument entirely, and the browser uses the requested host as the domain. It’s the same effect, ultimately.

Leaving COOKIE_DOMAIN unset causes WP to use the site’s domain, which causes the problem. So, COOKIE_DOMAIN should be set, at this time. Perhaps, in the future, the software will choose he right domain.

Leave a Reply