Streaming live at 10am (PST)

Cookie notice bar - Javascript

Hi all,

I have made a cookie notice bar.
I also added some javascript to disable to cookiebar when a user already accepted, however the cookiebar stays active even when you already accepted.

Sharelink: https://preview.webflow.com/preview/vigere-development?utm_medium=preview_link&utm_source=dashboard&utm_content=vigere-development&preview=a783aff26401ce40eb8fe0fca63c750f&mode=preview

I’m using the following script. The cookie is being recorded but on page reload the cookiebar still shows.

 <script>
const cookieContainer = document.querySelector(".cookienoticecontainer");
const cookieButton = document.querySelector(".cookie-btn");

cookieButton.addEventListener("click", () => {
  cookieContainer.classList.remove("active");
  localStorage.setItem("cookieBannerDisplayed", "true");
});

setTimeout(() => {
  if (!localStorage.getItem("cookieBannerDisplayed")) {
    cookieContainer.classList.add("active");
  }
}, 2000);
</script>

Anyone that could help with this?

Thanks!