From 97644db524d00ba6166813117e44e32a1323be31 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Wed, 24 Jun 2015 17:39:21 +0200 Subject: [PATCH 1/3] custom cookie path & expirydays --- cookieconsent.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cookieconsent.js b/cookieconsent.js index 882ed4e3..3cef63dc 100644 --- a/cookieconsent.js +++ b/cookieconsent.js @@ -91,11 +91,12 @@ return null; }, - setCookie: function (name, value, expirydays) { + setCookie: function (name, value, expirydays, path) { var exdate = new Date(); - expirydays = expirydays || 365; + expirydays = (typeof expirydays === 'undefined') ? 365 : expirydays; + path = (typeof path === 'undefined') ? 'default' : path; exdate.setDate(exdate.getDate() + expirydays); - document.cookie = name + '=' + value + '; expires=' + exdate.toUTCString() + '; path=/' + document.cookie = name + '=' + value + '; expires=' + exdate.toUTCString() + '; path=' + path; }, addEventListener: function (el, event, eventListener) { @@ -219,6 +220,8 @@ link: null, container: null, // selector theme: 'light-floating', + cookiePath: '/', + cookieExpiryDays: 365, markup: [ '
', '
', @@ -315,7 +318,7 @@ }, setDismissedCookie: function () { - Util.setCookie(DISMISSED_COOKIE, 'yes'); + Util.setCookie(DISMISSED_COOKIE, 'yes', this.options.cookieExpiryDays, this.options.cookiePath); } }; From 56dec60ef7167f39eda60766a5343bb90c59c78e Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Tue, 21 Jul 2015 11:18:27 +0200 Subject: [PATCH 2/3] default path --- cookieconsent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookieconsent.js b/cookieconsent.js index 3cef63dc..da9aedca 100644 --- a/cookieconsent.js +++ b/cookieconsent.js @@ -94,7 +94,7 @@ setCookie: function (name, value, expirydays, path) { var exdate = new Date(); expirydays = (typeof expirydays === 'undefined') ? 365 : expirydays; - path = (typeof path === 'undefined') ? 'default' : path; + path = (typeof path === 'undefined') ? '/' : path; exdate.setDate(exdate.getDate() + expirydays); document.cookie = name + '=' + value + '; expires=' + exdate.toUTCString() + '; path=' + path; }, From 3a1248be81582dca4b95fbcb245d22b9c235f95b Mon Sep 17 00:00:00 2001 From: Adam Hutchinson Date: Tue, 28 Jul 2015 11:00:01 +0100 Subject: [PATCH 3/3] cleaned up code to match format of the rest of file --- cookieconsent.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cookieconsent.js b/cookieconsent.js index da9aedca..6cbe7c30 100644 --- a/cookieconsent.js +++ b/cookieconsent.js @@ -91,11 +91,13 @@ return null; }, - setCookie: function (name, value, expirydays, path) { + setCookie: function (name, value, expiryDays, path) { + expiryDays = expiryDays || 365; + path = path || '/'; + var exdate = new Date(); - expirydays = (typeof expirydays === 'undefined') ? 365 : expirydays; - path = (typeof path === 'undefined') ? '/' : path; - exdate.setDate(exdate.getDate() + expirydays); + exdate.setDate(exdate.getDate() + expiryDays); + document.cookie = name + '=' + value + '; expires=' + exdate.toUTCString() + '; path=' + path; }, @@ -220,8 +222,8 @@ link: null, container: null, // selector theme: 'light-floating', - cookiePath: '/', - cookieExpiryDays: 365, + path: '/', + expiryDays: 365, markup: [ '
', '
', @@ -318,7 +320,7 @@ }, setDismissedCookie: function () { - Util.setCookie(DISMISSED_COOKIE, 'yes', this.options.cookieExpiryDays, this.options.cookiePath); + Util.setCookie(DISMISSED_COOKIE, 'yes', this.options.expiryDays, this.options.path); } };