Modification gestion des cookies

This commit is contained in:
SylvainLelievre 2021-11-24 07:18:29 +01:00
parent 39aaa035b4
commit 020da0f9e3
2 changed files with 26 additions and 27 deletions

View File

@ -219,31 +219,30 @@ core.start = function() {
}
});
/**
* Traitement du formulaire cookies
*/
$("#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();
/**
* Traitement du formulaire cookies
*/
$("#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
var analytics = "<?php echo $this->getData(['config', 'seo', 'analyticsId']);?>";
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;
document.cookie = "ZWII_COOKIE_CONSENT=<?php echo str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF'])); ?>;" + domain + ";" + path + ";" + samesite + ";" + expires;
});
var analytics = "<?php echo $this->getData(['config', 'seo', 'analyticsId']);?>";
if( analytics.length > 0){
document.cookie = "ZWII_COOKIE_GA_CONSENT=" + $("#googleAnalytics").prop("checked") + "<?php echo $_SERVER['PHP_SELF']; ?>" +";" + domain + ";" + path + ";" + samesite + ";" + expires;
}
document.cookie = "ZWII_COOKIE_CONSENT=<?php echo $_SERVER['PHP_SELF']; ?>;" + domain + ";" + path + ";" + samesite + ";" + expires;
});
$("#cookieConsent .cookieClose").on("click", function() {
$(this).parents("#cookieConsent").fadeOut();
});
$("#cookieConsent .cookieClose").on("click", function() {
$(this).parents("#cookieConsent").fadeOut();
});
/**
* Choix de page dans la barre de membre

View File

@ -1173,7 +1173,7 @@ class common {
*/
public function showAnalytics() {
if( !empty($code = $this->getData(['config', 'seo', 'analyticsId'])) &&
$this->getInput('ZWII_COOKIE_GA_CONSENT') === 'true_'.str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF']))) {
$this->getInput('ZWII_COOKIE_GA_CONSENT') === 'true'.$_SERVER['PHP_SELF']) {
echo '<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id='. $code .'"></script>
<script>
@ -1190,7 +1190,7 @@ class common {
*/
public function showCookies() {
if( $this->getInput('ZWII_COOKIE_CONSENT') !== str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF'])) AND
if( $this->getInput('ZWII_COOKIE_CONSENT') !== $_SERVER['PHP_SELF'] AND
$this->getData(['config','cookieConsent']) === true
){