<p>If both sites share a common root domain, you can share cookies by using that root domain as the cookie domain for both sites. This way, a login stored in the cookie for one site will also apply to the other site. Session cookies will be shared as well.</p>
<p>To force Craft to use only the root domain for it's cookies, use the <a href="https://craftcms.com/docs/3.x/config/config-settings.html#defaultcookiedomain" rel="nofollow noreferrer">defaultCookieDomain directive</a>.</p>
<pre class="lang-php prettyprint-override"><code>// config/general.php

// mind the dot at the start
'defaultCookieDomain' =&gt; '.food.com',
</code></pre>
<p>There are some other settings that you should consider, depending on your setup and use-case those might lead to sessions not being applied correctly across both sites:</p>
<ul>
<li><a href="https://craftcms.com/docs/3.x/config/config-settings.html#requirematchinguseragentforsession" rel="nofollow noreferrer">requireMatchingUserAgentForSession</a></li>
<li><a href="https://craftcms.com/docs/3.x/config/config-settings.html#requireuseragentandipforsession" rel="nofollow noreferrer">requireUserAgentAndIpForSession</a></li>
<li><a href="https://craftcms.com/docs/3.x/config/config-settings.html#samesitecookievalue" rel="nofollow noreferrer">sameSiteCookieValue</a></li>
</ul>
<blockquote>
<p>Is there any SSO for multi-site.</p>
</blockquote>
<p>Not in the core, but there is this plugin in the store: <a href="https://plugins.craftcms.com/saml-sp" rel="nofollow noreferrer">SAML SSO Service Provider</a></p>

CC BY-SA 4.0
2021-10-29T03:16:17.697Z
Thank you it worked on me. I just added the `'defaultCookieDomain' => '.food.com',` in the global settings `'*' => []`
Jeriel Jacinto
CC BY-SA 4.0
2021-10-25T12:09:01.750Z
2021-10-25T12:09:01.750Z
MoritzLost
<p>I have a multi-site and they are under 1 root domain and the default site is <code>food.com</code> and <code>bread.food.com</code> is the additional site. How can I share the user session data of <code>food.com</code> to <code>bread.food.com</code>. My goal is, when I login to <code>food.com</code>, I should also be logged in to <code>bread.food.com</code>.</p>
<p>Is there any SSO for multi-site.</p>
<p>Thank you.</p>

<users><multi-site><multi-domain><current-user>
user session for Multi Site
# user session for Multi Site

(Asked by: username_0 on 2021-10-25)

I have a multi-site and they are under 1 root domain and the default site is `food.com` and `bread.food.com` is the additional site. How can I share the user session data of `food.com` to `bread.food.com`. My goal is, when I login to `food.com`, I should also be logged in to `bread.food.com`.

Is there any SSO for multi-site.

Thank you.

**Tags:** users, multi-site, multi-domain, current-user

---

## 1 answers

### Answer by username_1 on 2021-10-25. Score: 3 | Accepted answer

If both sites share a common root domain, you can share cookies by using that root domain as the cookie domain for both sites. This way, a login stored in the cookie for one site will also apply to the other site. Session cookies will be shared as well.
To force Craft to use only the root domain for it's cookies, use the defaultCookieDomain directive.
// config/general.php

// mind the dot at the start
'defaultCookieDomain' => '.food.com',

There are some other settings that you should consider, depending on your setup and use-case those might lead to sessions not being applied correctly across both sites:

requireMatchingUserAgentForSession
requireUserAgentAndIpForSession
sameSiteCookieValue


Is there any SSO for multi-site.

Not in the core, but there is this plugin in the store: SAML SSO Service Provider

> **Comments:**
> **username_0**: Thank you it worked on me. I just added the `'defaultCookieDomain' => '.food.com',` in the global settings `'*' => []`  

---

