modification du nom des cookies de consentement

This commit is contained in:
SylvainLelievre 2021-11-20 07:48:41 +01:00
parent 9485c2ba5a
commit 12bec0e14f
2 changed files with 62 additions and 57 deletions

View File

@ -230,15 +230,18 @@ core.start = function() {
expires = "expires=" + expires.toUTCString();
// Crée le cookie d'acceptation Google Analytics si nécessaire
<?php $analytics = $this->getData(['config', 'seo', 'analyticsId']);?>
<?php if( $analytics !== null AND $analytics !=='' ){ ?>
<?php if( $analytics !== null AND $analytics !=='' ){
$cookieName = 'ZWII_COOKIE_GA_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF']));?>
if(ga.checked){
document.cookie = "ZWII_COOKIE_GA_CONSENT=true;" + expires +";"+ samesite;
document.cookie = "<?php echo $cookieName; ?>=true;" + expires +";"+ samesite;
}
else{
document.cookie = "ZWII_COOKIE_GA_CONSENT=false;" + expires +";"+ samesite;
document.cookie = "<?php echo $cookieName; ?>=false;" + expires +";"+ samesite;
}
<?php } ?>
document.cookie = "ZWII_COOKIE_CONSENT=true;" + expires +";"+ samesite;
<?php }
$cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF']));
?>
document.cookie = "<?php echo $cookieName; ?>=true;" + expires +";"+ samesite;
});
$(".cookieBox .cookieClose").on("click", function() {
$(this).parents("#cookieConsent").fadeOut();

View File

@ -1172,8 +1172,9 @@ class common {
* Affiche le script Google Analytics
*/
public function showAnalytics() {
$cookieName = 'ZWII_COOKIE_GA_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF']));
if( !empty($code = $this->getData(['config', 'seo', 'analyticsId'])) &&
$this->getInput('ZWII_COOKIE_GA_CONSENT') === 'true') {
$this->getInput($cookieName) === 'true') {
echo '<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id='. $code .'"></script>
<script>
@ -1189,7 +1190,8 @@ class common {
* Affiche le consentement aux cookies
*/
public function showCookies() {
if($this->getInput('ZWII_COOKIE_CONSENT') !== 'true' AND $this->getData(['config','cookieConsent']) === true){ ?>
$cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF']));
if($this->getInput($cookieName) !== 'true' AND $this->getData(['config','cookieConsent']) === true){ ?>
<div id="cookieConsent">
<div class="cookieBox"><div class="cookieClose">X</div></div>
<?php $analytics = $this->getData(['config', 'seo', 'analyticsId']);?>