'How to set cookie for Sendinblue iframe subscription popup

I want to set a cookie when someone subscribes to a newsletter so the popup does not appear again. I am using an Iframe, so i cannot figure out how to set a cookie when someone subscribes. I am using Sendinblue for the pop-up, and when someone subscribes, the subscriber's email, first, and last name are added to a list. here is my code:

<!DOCTYPE html>
<html>

  <head>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
  </head>

  <body>

    <table height="100%" width="100%">
      <tr>
        <td id="iframeSubContainer" valign="middle" align="center">
        </td>
      </tr>
    </table>

    <script type="text/javascript">
      let x = document.cookie;
      let subscribeCookie = '';
      let showSubVar = '';

      function findCookieSub(subCookieArg) {
        let containsCookieSub = x.search('subscribeCookie=' + subCookieArg);
        if (containsCookieSub != -1) {
          subscribeCookie = subCookieArg;
        };
      };

      function setUpdatesCookie(cookieData) {
        document.cookie = "subscribeCookie=" + cookieData + "; expires=Thu, 01 Jan 2038 00:00:00 UTC; path=ymjyvikpcdbq-html.na.app.codingrooms.com/;";
      };

      
      var loadSubscribe = document.getElementById("iframeSubContainer");
      var subIframe = document.createElement("iframe");
      subIframe.src = "https://5eb037e3.sibforms.com/serve/MUIEAJ939z1Bq2LxF5Zhl4FTxrbO_BRWpsH3pI1Oc3BlfERyduUrKn8MZGOp_SfE8ANeCph9Ho774Ez3WHnEGB8HA2SUKdqotNxM9BrRc56WQOdxp2sXCz4l9pinjkJOMDiRsG9uY4SAvobb3Gv2BoKx_iWdBOaxVmg7qlkzPx6pzha-j8NErMxJXTB85a0OqOs-bLG8_y-Fi-xx";
      subIframe.width = "540";
      subIframe.height = "755";
      subIframe.frameBorder = "0";
      subIframe.scrolling = "no";
      subIframe.style["opacity"] = "1";
      subIframe.style["display"] = "block";
      subIframe.style["border"] = "none";
      subIframe.style["background"] = "white";
      subIframe.style["marginLeft"] = "auto";
      subIframe.style["marginRight"] = "auto";
      subIframe.style["maxWidth"] = "100%";



      findCookieSub('ABC12F8D666517C35280BF220F5390B1F0EF4BDBBC794AC59C95BBA0381BF91B'); // clicked the subscribe button on banner
      findCookieSub('621E19700FDCF51F959E420DE17869718703D6680B55D26D4DB5085A0B558FAE'); //did not click the subscribe button on banner




      if (subscribeCookie == "ABC12F8D666517C35280BF220F5390B1F0EF4BDBBC794AC59C95BBA0381BF91B") {

      }

      function loadSubIframeFadeIn(iframeID, ms) {
        loadSubscribe.appendChild(iframeID)
        fadeIn(iframeID, ms)
      }
      setUpdatesCookie("621E19700FDCF51F959E420DE17869718703D6680B55D26D4DB5085A0B558FAE")

      // event to trigger iframe loading
      if (subscribeCookie == "621E19700FDCF51F959E420DE17869718703D6680B55D26D4DB5085A0B558FAE" && showSubVar == "") {
        window.setTimeout(loadSubIframeFadeIn, 1000, subIframe, 1000)

      }

    </script>
  </body>
</html>

how can I get the cookie to set for the pop-up?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source