Verified Commit faf38d96 authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

set secure cookies

parent 9163a923
......@@ -127,6 +127,7 @@ function loadMatomo() {
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setDoNotTrack', 1]);
_paq.push(['trackPageView']);
_paq.push(['setSecureCookie', true]);
_paq.push(['setIgnoreClasses', ['no-tracking', 'colorbox']]);
_paq.push(['enableLinkTracking']);
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
......@@ -152,7 +153,7 @@ function clearMatomo() {
for (var i in cookies) {
var name = cookies[i].split('=')[0];
if (name.startsWith('_pk_')) {
Cookies.set(name, 0, { expires: -1, path: '/' });
Cookies.set(name, 0, { expires: -1, path: '/', SameSite: 'None', Secure: true });
}
}
console.log('cleared all cookies');
......@@ -166,7 +167,7 @@ $( document ).ready(function() {
$('.lap-cookies-accept').click(function (e) {
e.preventDefault(true);
console.log('clicked on accept');
Cookies.set('lap_cookie_agree', 1, { expires: parseInt(settings.expires), path: '/' });
Cookies.set('lap_cookie_agree', 1, { expires: parseInt(settings.expires), path: '/', SameSite: 'None', Secure: true });
hidelapCookieBanner();
//jQuery('#lap-cookies-banner').slideUp('slow');
jQuery('.lap-cookies-accept').addClass('disabled');
......@@ -180,7 +181,7 @@ $( document ).ready(function() {
e.preventDefault(true);
console.log('clicked on refuse');
clearMatomo();
Cookies.set('lap_cookie_agree', 0, { expires: parseInt(settings.expires), path: '/' });
Cookies.set('lap_cookie_agree', 0, { expires: parseInt(settings.expires), path: '/', SameSite: 'None', Secure: true });
hidelapCookieBanner();
//jQuery('#lap-cookies-banner').slideUp('slow');
jQuery('.lap-cookies-refuse').addClass('disabled');
......@@ -189,34 +190,27 @@ $( document ).ready(function() {
});
/* default mechanism */
if (!jQuery('body').hasClass('lap-cookies-proceed')) {
jQuery('body').addClass('lap-cookies-proceed');
if (window.doNotTrack || navigator.doNotTrack || navigator.msDoNotTrack || ('external' in window && 'msTrackingProtectionEnabled' in window.external)) {
if (window.doNotTrack == "1" || navigator.doNotTrack == "yes" || navigator.doNotTrack == "1" || navigator.msDoNotTrack == "1" || ('external' in window && 'msTrackingPronectionEnabled' in window.external && window.external.msTrackingProtectionEnabled())) {
/* Do Not Track is enabled => stop */
jQuery('.lap-cookies-dnt-inactive').hide(); // Hide no DNT message.
jQuery('.lap-cookies-accept, .lap-cookies-refuse').addClass('disabled');
}
if (window.doNotTrack || navigator.doNotTrack || navigator.msDoNotTrack || ('external' in window && 'msTrackingProtectionEnabled' in window.external)) {
if (window.doNotTrack == "1" || navigator.doNotTrack == "yes" || navigator.doNotTrack == "1" || navigator.msDoNotTrack == "1" || ('external' in window && 'msTrackingPronectionEnabled' in window.external && window.external.msTrackingProtectionEnabled())) {
/* Do Not Track is enabled => stop */
jQuery('.lap-cookies-accept, .lap-cookies-refuse').addClass('disabled');
}
jQuery('.lap-cookies-dnt-active').hide(); // Hide DNT message.
lapCookieAgree = getCookie('lap_cookie_agree');
console.log(lapCookieAgree);
if (lapCookieAgree == '0') {
/* Visitor refused our cookies => remove Matomo trace if present */
jQuery('.lap-cookies-refuse').addClass('disabled');
clearMatomo();
}
else if (lapCookieAgree == '1') {
/* Visitor accepted our cookies => load Matomo */
jQuery('.lap-cookies-accept').addClass('disabled');
loadMatomo();
}
else {
/* Visitor did not choose yet */
//var lapCookieAgree = Cookies.set('lap_cookie_agree', {path: '/'}); // do not set cookie
showlapCookieBanner();
}
}
lapCookieAgree = getCookie('lap_cookie_agree');
if (lapCookieAgree == '0') {
/* Visitor refused our cookies => remove Matomo trace if present */
jQuery('.lap-cookies-refuse').addClass('disabled');
clearMatomo();
}
else if (lapCookieAgree == '1') {
/* Visitor accepted our cookies => load Matomo */
jQuery('.lap-cookies-accept').addClass('disabled');
loadMatomo();
}
else {
/* Visitor did not choose yet */
showlapCookieBanner();
}
});
</script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment