CRM Extension- Iframe Cookie Issue

Hi guys, our web app fails user session validation when i try to display my widget in iframe after clicking on a button in deal card. The issue seems to be cookie not being allowed to set by Hubspot which fails the session validation.
Similar issue was reported by someone else almost 2 years ago
https://community.hubspot.com/t5/APIs-Integrations/Cookie-issue-in-Iframe/m-p/681968?profile.language=fr
Can anyone help with this?


@haroon957 wrote:

Hi guys, our web app fails user session validation when i try to display my widget in iframe after clicking on a button in deal card. The issue seems to be cookie not being allowed to set by Hubspot which fails the session validation.
Similar issue was reported by someone else almost 2 years ago
https://community.hubspot.com/t5/APIs-Integrations/Cookie-issue-in-Iframe/m-p/681968?profile.language=fr
Can anyone help with this?


This issue often arises due to modern browser security measures that block third-party cookies by default. To address this, first, ensure your cookies have the SameSite=None; Secure attributes, which allow cookies to be sent in a third-party context if the connection is secure (HTTPS). Additionally, make sure your server is correctly configured for Cross-Origin Resource Sharing (CORS) by setting appropriate headers to enable communication between your app and the iframe content. Another approach is to use the postMessage API for secure communication between the iframe and the parent page, thereby avoiding cookie restrictions entirely. Also, review your Content Security Policy (CSP) headers to ensure they permit embedding your widget in an iframe on the HubSpot domain. Finally, consider browser-specific solutions, as some browsers, like Safari, have stricter third-party cookie policies.