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.

2 thoughts on “WordPress’ COOKIE_DOMAIN and Multisite with Domain Mapping”

  1. Hello!

    I’m currently playing in a sandbox install of WPMS and trying to get things running using multi site sub-site directories, and domain mapping without using the WPMU plugin. I’ve put a good 12+ hours into trying to understand and troubleshoot the problems, but not having much luck. I get a cookie message error when i try to go into the admin of the mapped domain sub-sites, and I get internal server errors when going to any link within the sub-site of a mapped domain site. such as domain.com/hello-world.

    Is there any chance i could ask for your expertise on this?

    here is one of the mapped domains that is pointing to one of the sub-sites

    http://utahartspassport.org/

    Thanks for your time! And thanks for this post.

Leave a Reply