Skip to content

Commit

Permalink
Merge pull request #31 from silktide/pr/22
Browse files Browse the repository at this point in the history
Expiry date and path
  • Loading branch information
adjohu committed Jul 28, 2015
2 parents 9e9fb9a + 3a1248b commit 61a727f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cookieconsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@
return null;
},

setCookie: function (name, value, expirydays) {
setCookie: function (name, value, expiryDays, path) {
expiryDays = expiryDays || 365;
path = path || '/';

var exdate = new Date();
expirydays = expirydays || 365;
exdate.setDate(exdate.getDate() + expirydays);
document.cookie = name + '=' + value + '; expires=' + exdate.toUTCString() + '; path=/'
exdate.setDate(exdate.getDate() + expiryDays);

document.cookie = name + '=' + value + '; expires=' + exdate.toUTCString() + '; path=' + path;
},

addEventListener: function (el, event, eventListener) {
Expand Down Expand Up @@ -219,6 +222,8 @@
link: null,
container: null, // selector
theme: 'light-floating',
path: '/',
expiryDays: 365,
markup: [
'<div class="cc_banner-wrapper {{containerClasses}}">',
'<div class="cc_banner cc_container cc_container--open">',
Expand Down Expand Up @@ -316,7 +321,7 @@
},

setDismissedCookie: function () {
Util.setCookie(DISMISSED_COOKIE, 'yes');
Util.setCookie(DISMISSED_COOKIE, 'yes', this.options.expiryDays, this.options.path);
}
};

Expand Down

0 comments on commit 61a727f

Please sign in to comment.