I have a magento 2 website where we want to have 3 different stores on 3 different domains. We want to share cart and customer session on the different websites. Each website/store will have different catalog.

Now my questions follow as:

  1. What should be the proper configuration of stores to achieve this?
  2. Is it possible to achieve this in Magento 2?
  • How do you want to share the cart if the stores will have a different catalog?
    – mbalparda
    Commented Jul 20, 2016 at 16:52
  • All products from first site should also appear in cart of second site.
    – Arvind07
    Commented Jul 20, 2016 at 16:55
  • So "Each website/store will have different catalog." is not correct or maybe I'm missing something?
    – mbalparda
    Commented Jul 20, 2016 at 16:58
  • I need that product added to cart in site1 should be visible in cart of site 2. and yes catalog will be different.
    – Arvind07
    Commented Jul 20, 2016 at 17:07
  • Or if we need, we can have same catalog as well. If that makes things easier..
    – Arvind07
    Commented Jul 20, 2016 at 17:09

2 Answers 2


Finally I sorted it out. So for sake of others, here is how we share cart between Magento multistore setup on different domains:

Magento configuration:

  1. Create 2 different stores, store views under a single website. enter image description here

Also check if you have assigned respective root categories to their stores like this:

enter image description here

  1. Assign Domains to Stores

We will assign our primary domain to the main store.

a. Go to Admin -> Stores -> Settings -> Configuration. Now click on General -> Web in the left tab. In the “Base URLs” section, update the “Base URL” configuration. Here you will add your primary domain like http://mystore.com/

b. If you have SSL enabled domain, add the https://mystore.com in “Base URLs (Secure)” section.

enter image description here

c. Open the “Default Cookie Settings” section on the same page

d. Set the “Cookie Path” setting to “/”.

enter image description here

e. Save the configuration.

Now select the second store view from store selector dropdown on the top. Perform the above specified steps for second store also.

  1. Share Customer Accounts

If we want to share the customer accounts on different stores, we will have to change one more setting.

a. Go to Stores -> Customers -> Customer Configuration tab.

b. Find the “Account Sharing Options” section.

c. Set the “Share Customer Accounts” setting to “Global”

d. Save the configuration

enter image description here

Server Configuration Next step is to configure our Web server (Apache/Nginx) to enable multistore installation. Lets see how to configure Apache. a. Open the .htaccess at the root of the Magento 2 installation b. On the top of .htaccess file, add following lines:

SetEnvIf Host myfurniturestore.com MAGE_RUN_CODE=store1
SetEnvIf Host myfurniturestore.com MAGE_RUN_TYPE=store
SetEnvIf Host ^myfurniturestore.com MAGE_RUN_CODE=store1
SetEnvIf Host ^myfurniturestore.com MAGE_RUN_TYPE=store

SetEnvIf Host myfashionstore.com MAGE_RUN_CODE=store2
SetEnvIf Host myfashionstore.com MAGE_RUN_TYPE=store
SetEnvIf Host ^myfashionstore.com MAGE_RUN_CODE=store2
SetEnvIf Host ^myfashionstore.com MAGE_RUN_TYPE=store


But remember that Magento 2 cant share the cart and customer session if the different stores are accessed directly. Because Magento needs to see the Session ID to enable cart and customer account sharing. So we need to add the SID parameter to URLs pointing to other stores from our site. It is better to use Magento’s default store switcher for moving between different stores so that cart and customer session can be shared.

More explanation: http://www.webspeaks.in/2016/08/share-cart-magento-2-multistore-website.html

  • 1
    IF we keep the cookie domain blank , shared cart is not working Commented Apr 27, 2020 at 13:38
  • does it work for multiple website as well?
    – Kul
    Commented Oct 25, 2020 at 8:13
  • @Kul yes it will work for multi websites
    – Arvind07
    Commented Oct 26, 2020 at 11:26
  • The SID is removed in Magento 2.4.x for security reasons. Commented Apr 10, 2022 at 21:59

I am currently doing this with 5 stores/domains & separate products per store - TugaSunwear.com (Magento 1.9.2.x)

The most important issues we found were to have cookies set properly, SID being added to URL to ensure session is carried between stores, and a few standard magento configuration changes to allow customer accounts to be shared between store views/domains.

From how you are setup currently, what issues are you running into?

  • Thanks Steven. I have not setup the stores till now. I am planning on what is the best way to do that. Should I create multie websites/stores/store views?
    – Arvind07
    Commented Jul 21, 2016 at 3:37
  • Our setup is 1 Website and 5 Stores, each store with 1 store view. Although, it is my understanding that products can be shared between websites, as well as stores/store views. You just need to check mark the website the product is allowed on.
    – Steven J
    Commented Jul 21, 2016 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.