Gestion des cookies

This commit is contained in:
fredtempez 2022-01-25 11:36:11 +01:00
parent ee91af4bdc
commit 199022a244
1 changed files with 9 additions and 10 deletions

View File

@ -212,12 +212,11 @@ core.start = function() {
*/ */
$("#cookieForm").submit(function(event){ $("#cookieForm").submit(function(event){
// Varables des cookies // Variables des cookies
var samesite = "samesite=lax";
var getUrl = window.location; var getUrl = window.location;
var domain = "domain=" + getUrl.host; var domain = "domain=" + getUrl.host + ";";
var path = "path=" + getUrl.pathname.split('/')[1]; var path = "path=" + getUrl.pathname.split('/')[1] + ";";
var samesite = "samesite=lax";
var e = new Date(); var e = new Date();
e.setFullYear(e.getFullYear() + 1); e.setFullYear(e.getFullYear() + 1);
var expires = "expires=" + e.toUTCString(); var expires = "expires=" + e.toUTCString();
@ -226,18 +225,18 @@ core.start = function() {
var analytics = "<?php echo $this->getData(['config', 'seo', 'analyticsId']);?>"; var analytics = "<?php echo $this->getData(['config', 'seo', 'analyticsId']);?>";
// l'Id GA est défini dans la configuration, afficher la checkbox d'acceptation // l'Id GA est défini dans la configuration, afficher la checkbox d'acceptation
if( analytics.length > 0){ if( analytics.length > 0){
// Traitement du retour de la checkbox // Traitement du retour de la checkbox
if ($("#googleAnalytics").is(":checked")) { if ($("#googleAnalytics").is(":checked")) {
// L'URL du serveur faut TRUE // L'URL du serveur faut TRUE
document.cookie = "ZWII_COOKIE_GA_CONSENT=true;" + domain + ";" + path + ";" + samesite + ";" + expires;
document.cookie = "ZWII_COOKIE_GA_CONSENT=true;samesite=strict;" + domain + path + expires;
} else { } else {
document.cookie = "ZWII_COOKIE_GA_CONSENT=false;" + domain + ";" + path + ";" + samesite + ";" + expires; document.cookie = "ZWII_COOKIE_GA_CONSENT=false;samesite=strict;" + domain + path + expires;
} }
} }
// Stocke le cookie d'acceptation // Stocke le cookie d'acceptation
document.cookie = "ZWII_COOKIE_CONSENT=true;" + domain + ";" + path + ";" + samesite + ";" + expires; document.cookie = "ZWII_COOKIE_CONSENT=true;samesite=strict;" + domain + path + expires;
}); });