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.
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!