• Skip to primary navigation
  • Skip to content
  • Skip to footer

RedChamps

RedChamps Blog

Main navigation

  • Magento 1 Extensions
  • Magento 2 Extensions
  • Visit Store

Magento 2: AddToCart issue on subdomain

Troubleshooting · September 1, 2017

When the Magento 2 installation runs on both the main domain and the subdomain, you’ll notice that the ‘ Add to cart ‘ process doesn’t work on the subdomain (both the domains are open in the same browser).

This is a common issue with all the Magento 2 stores as the subdomain hosts the development or staging website.

We faced this issue ourselves as we have our main store on Magento 2. And our Magento 2 extension demo installation is on the subdomain.

We traced this problem and here’s the solution to add-to cart issue on the subdomain:

Problem:

The issue occurs due to a conflict of PHP session cookie named “PHPSESSID”. The subdomain starts reading main domain’s cookie when both are open in the same browser.

Solution:

We changed the PHP session name on the subdomain by adding the code given below at the beginning of Magento’s index.php file:

session_name(‘rcM2DEMO’)

You can replace the text ‘rcM2DEMO’ with any unique string you like. And you’re done!

  • Facebook
  • Twitter
  • Google+

Filed Under: Troubleshooting

Rav

Founder and Magento Certified Developer at RedChamps

Footer

Follow Us ON

  • Facebook
  • Twitter
Copyright © 2025 • Powered by RedChamps