Nom du cookie + nettoyage

This commit is contained in:
fredtempez 2021-11-22 13:46:16 +01:00
parent bf9e887c00
commit 84b4023e19
2 changed files with 20 additions and 22 deletions

View File

@ -223,26 +223,24 @@ 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();
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
<?php $analytics = $this->getData(['config', 'seo', 'analyticsId']);?>
<?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 = "<?php echo $cookieName; ?>=true;" + expires +";"+ samesite;
var analytics = "<?php echo $this->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;
}
else{
document.cookie = "<?php echo $cookieName; ?>=false;" + expires +";"+ samesite;
}
<?php }
$cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF']));
?>
document.cookie = "<?php echo $cookieName; ?>=true;" + expires +";"+ samesite;
document.cookie = "ZWII_COOKIE_CONSENT=true;" + domain + ";" + path + ";" + samesite + ";" + expires;
});
$("#cookieConsent .cookieClose").on("click", function() {
$(this).parents("#cookieConsent").fadeOut();
});

View File

@ -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){ ?>
<div id="cookieConsent">
<div class="cookieClose">X</div>
<h3><?php echo $this->getData(['config', 'cookies', 'cookiesTitleText']); ?></h3>