diff --git a/core/core.js.php b/core/core.js.php index abe89d1f..8b554b1b 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -219,30 +219,28 @@ core.start = function() { } }); - /** + /** * Traitement du formulaire cookies */ - $("#cookieForm").submit(function(event){ - const ga = document.getElementById('googleAnalytics'); - var samesite = "samesite=lax"; - var expires = new Date(); - expires.setFullYear(expires.getFullYear() + 1); - expires = "expires=" + expires.toUTCString(); + $("#cookieForm").submit(function(event){ + var samesite = "samesite=lax"; + var getUrl = window.location; + var domain = "domain=" + getUrl.host; + var path = "path=" + getUrl.pathname.split('/')[1]; + var samesite = "samesite=lax"; + var e = new Date(); + e.setFullYear(e.getFullYear() + 1); + var expires = "expires=" + e.toUTCString(); + // Crée le cookie d'acceptation Google Analytics si nécessaire - getData(['config', 'seo', 'analyticsId']);?> - - if(ga.checked){ - document.cookie = "=true;" + expires +";"+ samesite; - } - else{ - document.cookie = "=false;" + expires +";"+ samesite; - } - - document.cookie = "=true;" + expires +";"+ samesite; + var analytics = "getData(['config', 'seo', 'analyticsId']);?>"; + console.log(analytics.length ); + if( analytics.length > 0){ + document.cookie = "ZWII_COOKIE_CONSENT_GA=" + $("#googleAnalytics").prop("checked") + ";" + domain + ";" + path + ";" + samesite + ";" + expires; + } + document.cookie = "ZWII_COOKIE_CONSENT=true;" + domain + ";" + path + ";" + samesite + ";" + expires; }); + $("#cookieConsent .cookieClose").on("click", function() { $(this).parents("#cookieConsent").fadeOut(); }); diff --git a/core/core.php b/core/core.php index ad04608a..3adce250 100644 --- a/core/core.php +++ b/core/core.php @@ -1190,8 +1190,8 @@ class common { * Affiche le consentement aux cookies */ public function showCookies() { - $cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF'])); - if($this->getInput($cookieName) !== 'true' AND $this->getData(['config','cookieConsent']) === true){ ?> + //$cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF'])); + if($this->getInput('ZWII_COOKIE_CONSENT') !== 'true' AND $this->getData(['config','cookieConsent']) === true){ ?>
X

getData(['config', 'cookies', 'cookiesTitleText']); ?>