Sets new cookie domain and whether cookie should be available for subdomains or not.

@param string $domain
@param bool   $forSubdomains
170261
public function setDomain(string $domain = '', bool $forSubdomains = true): void
    {
        $subdomainIndicator = $forSubdomains === true ? '.' : '';
        $this->domain = \sprintf('%s%s', $subdomainIndicator, \preg_replace('/^(\.)?(preview\.)?/', '', $domain));
    }
217514
public function setPrimaryDomain($primaryDomain)
    {
        if (empty($primaryDomain)) {
            $this->primaryDomain = null;
            $this->primaryId = null;

            return;
        }

        $this->primaryDomain = $primaryDomain;
        $this->primaryId = $primaryDomain->getDomainId();
    }
1338989
public function isIgnoredDomain($domain)
    {
        if ($ignoreRegexes = $this->config()->get('ignore_domain_regexes')) {
            foreach ($ignoreRegexes as $ignore) {
                if (preg_match($ignore, $domain) > 0) {
                    return true;
                }
            }
        }

        return false;
    }
1333211
protected function validateDomainName($domain)
    {
        if (!array_key_exists($domain, $this->domains)) {
            throw new InvalidArgumentException(sprintf(
                'Domain "%s" is not valid. Valid domains are: %s',
                $domain,
                implode(', ', array_keys($this->domains))
            ));
        }
    }
12224
protected function isFromDomain($url, $domain)
    {
        if (!$domain) {
            return true;
        }

        $parsedUrl = parse_url($url);
        // if domain or subdomain
        if (
            isset($parsedUrl['host'])
            && (
                $parsedUrl['host'] == $domain
                || fnmatch('*.' . $domain, $parsedUrl['host'])
            )
        ) {
            return true;
        }

        return false;
    }
890366
public function updateDomainAction(Domain $domain)
    {
        $this->domainRepository->update($domain);
        $this->addFlashMessage('The domain "%s" has been updated.', 'Domain updated', Message::SEVERITY_OK, [htmlspecialchars($domain)], 1412373069);
        $this->unsetLastVisitedNodeAndRedirect('edit', null, null, ['site' => $domain->getSite()]);
    }
571494
public function startSession($domain) {
        $this->cookieLocation = str_replace('APP_ROOT', APP_ROOT, $this->cookieLocation);
        if (!is_dir($this->cookieLocation))
            mkdir($this->cookieLocation);
        if (!is_dir($this->cookieLocation)) {
            $this->error($this->error = "Can't create folder {$this->cookieLocation}");
        }
        $this->currentFile = $this->cookieLocation . date('YmdHis') . '-' . md5($domain);
        fclose(fopen($this->currentFile, 'w'));
    }
1236933
public function addDomain(DomainConfiguration ...$domains)
    {
        foreach ($domains as $domain) {
            $this->domains[$domain->getDomainName()] = $domain;
        }

        return $this;
    }
326008
public function deleteDomainAction(Domain $domain)
    {
        $site = $domain->getSite();
        if ($site->getPrimaryDomain() === $domain) {
            $site->setPrimaryDomain(null);
            $this->siteRepository->update($site);
        }
        $this->domainRepository->remove($domain);
        $this->addFlashMessage('The domain "%s" has been deleted.', 'Domain deleted', Message::SEVERITY_OK, [htmlspecialchars($domain)], 1412373310);
        $this->unsetLastVisitedNodeAndRedirect('edit', null, null, ['site' => $site]);
    }
200460
public static void setCookie(HttpServletResponse response, String name,
                                 String value, String domain, int maxAge) {
        if (value == null) {
            value = "";
        }
        Cookie cookie = new Cookie(name, value);
        cookie.setMaxAge(maxAge);
        if (domain != null && !"".equals(domain)) {
            cookie.setDomain(domain);
        }
        cookie.setPath("/");
        response.addCookie(cookie);
    }
153300
public function add($cookie)
    {
        // If the name string is empty (but not 0), ignore the set-cookie
        // string entirely.
        $name = $cookie->name();

        if (!$name && $name !== '0') {
            return false;
        }

        // Only allow cookies with set and valid domain, name, value
        $result = $cookie->isValid();
        if ($result !== true) {
            if ($this->_strictMode) {
                throw new RuntimeException('Invalid cookie: ' . $result);
            } else {
                $cookieValue = $cookie->value();
                if ($cookieValue === null || $cookieValue === '') {
                    $this->clear($cookie->domain(), $cookie->path(), $cookie->name());
                }
                return false;
            }
        }

        // Resolve conflicts with previously set cookies
        foreach ($this->_data as $i => $c) {

            // Two cookies are identical, when their path, and domain are
            // identical.
            if ($c->path() != $cookie->path() ||
                $c->domain() != $cookie->domain() ||
                $c->name() != $cookie->name()
            ) {
                continue;
            }

            // The previously set cookie is a discard cookie and this one is
            // not so allow the new cookie to be set
            if (!$cookie->discard() && $c->discard()) {
                unset($this->_data[$i]);
                continue;
            }

            // If the new cookie's expiration is further into the future, then
            // replace the old cookie
            if ($cookie->expires() > $c->expires()) {
                unset($this->_data[$i]);
                continue;
            }

            // If the value has changed, we better change it
            if ($cookie->value() !== $c->value()) {
                unset($this->_data[$i]);
                continue;
            }

            // The cookie exists, so no need to continue
            return false;
        }

        $this->_data[] = $cookie;

        return true;
    }
848957
public function newDomainAction(Domain $domain = null, Site $site = null)
    {
        $this->view->assignMultiple([
            'domain' => $domain,
            'site' => $site,
            'schemes' => [null => '', 'http' => 'HTTP', 'https' => 'HTTPS']
        ]);
    }
945484
public function setRawCookie($key, $value, $expires = null, $domain = '-', $path = '/')
    {
        $domain = strtolower($domain);
        if (substr($domain, 0, 1) === '.') {
            $domain = substr($domain, 1);
        }
        if (!isset($this->_cookies[$domain])) {
            $this->_cookies[$domain] = [];
        }
        if (!isset($this->_cookies[$domain][$path])) {
            $this->_cookies[$domain][$path] = [];
        }
        $list = &$this->_cookies[$domain][$path];
        if ($value === null || $value === '' || ($expires !== null && $expires < time())) {
            unset($list[$key]);
        } else {
            $list[$key] = ['value' => $value, 'expires' => $expires];
        }
    }
249834
function setDomain()
    {
        $this->domains = func_get_args();
        $this->removeDNProp('id-at-commonName');
        $this->setDNProp('id-at-commonName', $this->domains[0]);
    }
972270
public void setDomains(@NonNull EnumSet<LogDomain> domains) {
        if (domains == null) { throw new IllegalArgumentException("domains cannot be null."); }

        logDomains = domains;
    }
662648
public function removeDomain($domain)
    {
        if (isset($this->domains[$domain])) {
            unset($this->domains[$domain]);
        }

        return $this;
    }
1338943
public void setDomains(java.util.Collection<DomainSummary> domains) {
        if (domains == null) {
            this.domains = null;
            return;
        }

        this.domains = new java.util.ArrayList<DomainSummary>(domains);
    }