Skip to content

Commit

Permalink
Merge pull request #33 from silktide/domain-option
Browse files Browse the repository at this point in the history
added domain option
  • Loading branch information
oliveremberton committed Jul 28, 2015
2 parents 61a727f + 6cf7430 commit 5d08c6a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions cookieconsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,25 @@
return null;
},

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

var exdate = new Date();
exdate.setDate(exdate.getDate() + expiryDays);

document.cookie = name + '=' + value + '; expires=' + exdate.toUTCString() + '; path=' + path;
var cookie = [
name + '=' + value,
'expires=' + exdate.toUTCString(),
'path=' + path || '/'
];

if (domain) {
cookie.push(
'domain=' + domain
);
}

document.cookie = cookie.join(';');
},

addEventListener: function (el, event, eventListener) {
Expand Down Expand Up @@ -222,6 +233,7 @@
link: null,
container: null, // selector
theme: 'light-floating',
domain: null, // default to current domain.
path: '/',
expiryDays: 365,
markup: [
Expand Down Expand Up @@ -321,7 +333,7 @@
},

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

Expand Down

0 comments on commit 5d08c6a

Please sign in to comment.