From a5f0900963b1025ce03e073aed72052e497655c6 Mon Sep 17 00:00:00 2001 From: Thomas Combe Date: Thu, 24 May 2018 09:47:44 +0200 Subject: [PATCH] Allow user to select tarteaucitron cookie domain (for multi-site) --- tarteaucitron.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 88cd673..0cada71 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -865,14 +865,15 @@ var tarteaucitron = { expireTime = time + 31536000000, // 365 days regex = new RegExp("!" + key + "=(wait|true|false)", "g"), cookie = tarteaucitron.cookie.read().replace(regex, ""), - value = 'tarteaucitron=' + cookie + '!' + key + '=' + status; - - if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) { + value = 'tarteaucitron=' + cookie + '!' + key + '=' + status, + domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? 'domain=' + tarteaucitron.parameters.cookieDomain + ';' : ''; + + if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) { tarteaucitron.pro('!' + key + '=' + status); } d.setTime(expireTime); - document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;'; + document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;' + domain; }, "read": function () { "use strict";