title: Check if cookie exists and add style to class
body: <p>I'm trying to get my script to check if a cookie exists. If it exists then set the class to display none, and when it does not exist then display block.</p>
  <p>After pressing the button, the popup disappears, but after reloading the page, it is displayed again, despite the fact that the cookie still exists.</p>
  <p>I have this script in my footer.</p>
  <pre><code>&lt;script&gt;
    setCookie = (cName, cValue, expDays) =&gt; {
      var date = new Date();
      date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
      var expires = &quot;expires=&quot;+ date.toUTCString();
      document.cookie = cName + &quot;=&quot; + cValue + &quot;;&quot; + expires + &quot;; path=/&quot;;
    }
  
    getCookie = (cName) =&gt; {
      const name = cName + &quot;=&quot;;
      const cDecoded = decodeURIComponent(document.cookie);
      const cArr = cDecoded .split(&quot;; &quot;);
      var value;
      cArr.forEach(val =&gt; {
        if (val.indexOf(name) === 0) value = val.substring(name.length);
      })
    }
  
    document.querySelector(&quot;#gdprCookiePopupAccept&quot;).addEventListener(&quot;click&quot;, () =&gt;  {
      document.querySelector(&quot;.gdprCookiePopup&quot;).style.display = &quot;none&quot;;
      setCookie(&quot;gdprAccept&quot;, true, 90)
    })
  
    var acceptCookie = getCookie(&quot;gdprAccept&quot;);
  
    if(acceptCookie !== 'null') {
      document.querySelector(&quot;.gdprCookiePopup&quot;).style.display = &quot;block&quot;;
    } else {
      document.querySelector(&quot;.gdprCookiePopup&quot;).style.display = &quot;none&quot;;
    };
  
  &lt;/script&gt;
  </code></pre>
  <p>what am I doing wrong?</p>