From a1104f6a24ff3b7e4c8417f6919e8cfde0df3fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Dellac=C3=A0?= Date: Fri, 10 Jul 2020 12:50:55 +0200 Subject: [PATCH] made cookie last 5 years --- scripts/policy-popup.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/policy-popup.js b/scripts/policy-popup.js index 394aee9..122db7c 100644 --- a/scripts/policy-popup.js +++ b/scripts/policy-popup.js @@ -6,9 +6,9 @@ function openPolicyPopup() { function agreePolicyPopup() { const _paq = window._paq || []; - _paq.push(['rememberConsentGiven']); + _paq.push(['rememberConsentGiven', 43800]); $("#policy-popup").fadeOut(1000); // Disable the div - document.cookie = "consentGiven=true;SameSite=Lax"; // todo: check if already present? also, firefox was throwing a warning... + setCookie("consentGiven", "true", 1825) // todo: check if already present? also, firefox was throwing a warning... } function getCookie(cname) { @@ -26,3 +26,13 @@ function getCookie(cname) { } return ""; } + +function setCookie(name, value, days) { + var expires = ""; + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days*24*60*60*1000)); + expires = "; expires=" + date.toUTCString(); + } + document.cookie = name + "=" + (value || "") + expires + "; path=/;SameSite=Lax"; +}