Magento 2 in Ionic 3 iframe set cookie SameSite=None instead of the defaulted SameSite=LAX

Magento 2 in Ionic 3 iframe set cookie SameSite=None instead of the defaulted SameSite=LAX

September 1, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento 2 in Ionic 3 iframe set cookie SameSite=None instead of the defaulted SameSite=LAX

If you’re facing issues with Magento 2 cart functionality when using an Ionic 3 iframe, the problem likely stems from the SameSite attribute of session cookies being set to LAX by default. This can prevent items from being added to your cart correctly.

Let’s dive into understanding this issue and how to resolve it in your Magento 2 setup.

Understanding SameSite Cookies and Magento 2

In modern web development, the SameSite attribute controls where cookies are sent. The default for new cookies is LAX, which means they are included with top-level requests only if the cookie’s domain matches the site of the request.

However, for certain cross-site scenarios like those involving iframes (which are common in mobile app development), you may need to set this attribute to None instead. This allows the cookie to be sent along with any HTTP request regardless of the originating site.

Setting SameSite=None in Magento 2

To resolve your issue, you’ll need to manually set the SameSite attribute of session cookies to None in your Magento 2 configuration.

Here’s how:

  1. Open your Magento 2 installation and navigate to the app/code/Magento/Session/etc/session.xml file.
<session>
    <value name="session_same_site_cookie">NONE</value>
</session>

Modify the session_same_site_cookie value from its default LAX to NONE.

  1. Save the changes and clear your Magento cache. You can do this in the admin panel by going to System > Cache Management and clicking “Flush Magento Cache”.

Testing Your Changes

After making these modifications, refresh the page where your Ionic 3 iframe is displayed.

If everything is set up correctly:

  • The “Adding…” state should no longer persist indefinitely when adding items to the cart.
  • You should see the item being successfully added to the cart.
  • The network warnings regarding SameSite cookies should now be resolved.

Best Practices for Magento 2 and Iframes

While this solution addresses your immediate issue, it’s important to consider security implications:

  1. Secure Cookies: Always set the secure attribute for your session cookies to ensure they are only sent over HTTPS connections.
<session>
    <value name="session_same_site_cookie">NONE</value>
    <value name="session_cookie_secure">1</value>  // Set this line
</session>
  1. HttpOnly and SameSite=None: Be aware that using SameSite=None with HttpOnly cookies is generally discouraged due to security risks.

  2. Review Your Setup: Double-check your iframe setup to ensure it’s properly secured, especially if you’re dealing with sensitive data like customer information or financial transactions.

Conclusion

Setting the SameSite attribute of session cookies to None in Magento 2 can resolve cart functionality issues when using an Ionic framework within an iframe. Always remember to follow best security practices and thoroughly test your setup after making any changes to cookie configuration.

For more advanced Magento development topics, you might find our guide on Best Practices for Laravel and Vue.js Integration with Magento 2 helpful as well.

Magento 2 Checkout Cache Themes

Our network