Nom des cookies unique
This commit is contained in:
parent
bf9e887c00
commit
c004fec8c9
@ -221,27 +221,25 @@ core.start = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Traitement du formulaire cookies
|
* Traitement du formulaire cookies
|
||||||
*/
|
*/
|
||||||
$("#cookieForm").submit(function(event){
|
$("#cookieForm").submit(function(event){
|
||||||
const ga = document.getElementById('googleAnalytics');
|
const ga = document.getElementById('googleAnalytics');
|
||||||
var samesite = "samesite=lax";
|
var samesite = "samesite=lax";
|
||||||
var expires = new Date();
|
var expires = new Date();
|
||||||
expires.setFullYear(expires.getFullYear() + 1);
|
expires.setFullYear(expires.getFullYear() + 1);
|
||||||
expires = "expires=" + expires.toUTCString();
|
expires = "expires=" + expires.toUTCString();
|
||||||
// Crée le cookie d'acceptation Google Analytics si nécessaire
|
// Crée le cookie d'acceptation Google Analytics si nécessaire
|
||||||
<?php $analytics = $this->getData(['config', 'seo', 'analyticsId']);?>
|
<?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']));?>
|
$path = str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF']));?>
|
||||||
if(ga.checked){
|
if(ga.checked){
|
||||||
document.cookie = "<?php echo $cookieName; ?>=true;" + expires +";"+ samesite;
|
document.cookie = "ZWII_COOKIE_GA_CONSENT=true_<?php echo $path;?>;" + expires +";"+ samesite;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
document.cookie = "<?php echo $cookieName; ?>=false;" + expires +";"+ samesite;
|
document.cookie = "ZWII_COOKIE_GA_CONSENT=false_<?php echo $path;?>;" + expires +";"+ samesite;
|
||||||
}
|
}
|
||||||
<?php }
|
<?php } ?>
|
||||||
$cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF']));
|
document.cookie = "ZWII_COOKIE_CONSENT=true_<?php echo str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF'])); ?>;" + expires +";"+ samesite;
|
||||||
?>
|
|
||||||
document.cookie = "<?php echo $cookieName; ?>=true;" + expires +";"+ samesite;
|
|
||||||
});
|
});
|
||||||
$("#cookieConsent .cookieClose").on("click", function() {
|
$("#cookieConsent .cookieClose").on("click", function() {
|
||||||
$(this).parents("#cookieConsent").fadeOut();
|
$(this).parents("#cookieConsent").fadeOut();
|
||||||
|
@ -1172,9 +1172,8 @@ class common {
|
|||||||
* Affiche le script Google Analytics
|
* Affiche le script Google Analytics
|
||||||
*/
|
*/
|
||||||
public function showAnalytics() {
|
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'])) &&
|
if( !empty($code = $this->getData(['config', 'seo', 'analyticsId'])) &&
|
||||||
$this->getInput($cookieName) === 'true') {
|
$this->getInput('ZWII_COOKIE_GA_CONSENT') === 'true_'.str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF']))) {
|
||||||
echo '<!-- Global site tag (gtag.js) - Google Analytics -->
|
echo '<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id='. $code .'"></script>
|
<script async src="https://www.googletagmanager.com/gtag/js?id='. $code .'"></script>
|
||||||
<script>
|
<script>
|
||||||
@ -1190,8 +1189,7 @@ class common {
|
|||||||
* Affiche le consentement aux cookies
|
* Affiche le consentement aux cookies
|
||||||
*/
|
*/
|
||||||
public function showCookies() {
|
public function showCookies() {
|
||||||
$cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF']));
|
if($this->getInput('ZWII_COOKIE_CONSENT') !== 'true_'.str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF'])) AND $this->getData(['config','cookieConsent']) === true){ ?>
|
||||||
if($this->getInput($cookieName) !== 'true' AND $this->getData(['config','cookieConsent']) === true){ ?>
|
|
||||||
<div id="cookieConsent">
|
<div id="cookieConsent">
|
||||||
<div class="cookieClose">X</div>
|
<div class="cookieClose">X</div>
|
||||||
<h3><?php echo $this->getData(['config', 'cookies', 'cookiesTitleText']); ?></h3>
|
<h3><?php echo $this->getData(['config', 'cookies', 'cookiesTitleText']); ?></h3>
|
||||||
|
Loading…
Reference in New Issue
Block a user