# Cartcontext between sub domains

**URL:** <https://forum.litium.com/t/cartcontext-between-sub-domains/3116>\
**Category:** Questions\
**Tags:** litium-8\
**Created:** [October 25, 2023, 8:48am UTC](https://forum.litium.com/t/cartcontext-between-sub-domains/3116 "2023-10-25T08:48:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Totte](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@Totte](https://forum.litium.com/u/Totte)\
**Post date:** [October 25, 2023, 8:48am UTC](https://forum.litium.com/t/cartcontext-between-sub-domains/3116/1 "2023-10-25T08:48:54Z")

</div>

Hello.

I have two subdomains:  
[a.example.com](http://a.example.com)  
[b.example.com](http://b.example.com)

How do I make sure that the cart is saved when I switch from one subdomain to another?

Litium version: 8.11.6

---

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [October 25, 2023, 9:12am UTC](https://forum.litium.com/t/cartcontext-between-sub-domains/3116/2 "2023-10-25T09:12:21Z")

</div>

You can tell litium to save the cart.  
Since it is two different domains cookies will be handled in same manner as if they where two completely different domains.

/Litium/ECommerce/SettingsShoppingCart.aspx

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/c96ec261c396bfbef5762de06e497a462d6f4865.png)

---

<div class="post-metadata">

**Author:** ![Totte](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@Totte](https://forum.litium.com/u/Totte)\
**Post date:** [October 25, 2023, 9:57am UTC](https://forum.litium.com/t/cartcontext-between-sub-domains/3116/3 "2023-10-25T09:57:52Z")

</div>

I remember that setting - but I can’t seem to find it in L8.

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/59e366f02f11eba5521624c61deb235ddc63aef9.png)

---

<div class="post-metadata">

**Author:** ![Totte](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@Totte](https://forum.litium.com/u/Totte)\
**Post date:** [October 31, 2023, 10:54am UTC](https://forum.litium.com/t/cartcontext-between-sub-domains/3116/4 "2023-10-31T10:54:12Z")

</div>

How and when is the cart-context cookie set?

---

<div class="post-metadata">

**Author:** ![Totte](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@Totte](https://forum.litium.com/u/Totte)\
**Post date:** [October 31, 2023, 11:33am UTC](https://forum.litium.com/t/cartcontext-between-sub-domains/3116/5 "2023-10-31T11:33:08Z")

</div>

I will try setting the domain using OnAppendCookie for the CookiePolicyOptions

---

<div class="post-metadata">

**Author:** ![utku](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/utku/32/62_2.png) [@utku](https://forum.litium.com/u/utku)\
**Post date:** [October 31, 2023, 12:51pm UTC](https://forum.litium.com/t/cartcontext-between-sub-domains/3116/6 "2023-10-31T12:51:23Z")

</div>

HI you can try this in `services.Configure<CookiePolicyOptions>()` on the Startup.cs:

```auto
options.OnAppendCookie = x =>
{
    if (x.Context.Request.Host.Host.EndsWith(".example.com"))
    {
        x.CookieOptions.Domain = ".example.com";
    }
};
options.OnDeleteCookie = x =>
{
    if (x.Context.Request.Host.Host.EndsWith(".example.com"))
    {
        x.CookieOptions.Domain = ".example.com";
    }
};

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [November 28, 2023, 12:52pm UTC](https://forum.litium.com/t/cartcontext-between-sub-domains/3116/7 "2023-11-28T12:52:00Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
