Set the iframeDomain Cookie in Sites and Communities in Internet Explorer

URL variables, such as _iframeDomain, aren’t always saved when navigating between pages in Internet Explorer. This behavior prevented users from embedding some pages in iframes. Now, if the _iframeDomain variable isn’t present, iframes are allowed on the whitelisted URL domain set in the iframeDomain cookie.

Where: This change applies to all communities accessed through Lightning Experience and Salesforce Classic in Essentials, Enterprise, Performance, Unlimited, and Developer editions.

How: Create a Cookie class using the iframeDomain value. This cookie allows framing by

Cookie iframeDomainCookie = ApexPages.currentPage().getCookies().get('iframeDomain');

if (iframeDomainCookie == null) {
    iframeDomainCookie = new Cookie('iframeDomain','');

    // Set the new cookie for the page
    ApexPages.currentPage().setCookies(new Cookie[]{iframeDomainCookie});