Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add domain parameter for the set function #5

Closed
judithtarot opened this issue Dec 21, 2012 · 1 comment
Closed

Add domain parameter for the set function #5

judithtarot opened this issue Dec 21, 2012 · 1 comment

Comments

@judithtarot
Copy link

This is a nice way to do cookies, but I need to set the domain explicitly sometimes:

diff --git a/lib/monster.js b/lib/monster.js
index daae4c6..c6d61e6 100644
--- a/lib/monster.js
+++ b/lib/monster.js
@@ -1,10 +1,11 @@
var monster = {

  • set: function(name, value, days, path) {
  • set: function(name, value, days, path, domain) {
    var date = new Date(),
    expires = '',
    type = typeof(value),
    valueToUse = '';
    path = path || "/";
  • domain = domain || null;
    if (days) {
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    expires = "; expires=" + date.toGMTString();
    @@ -16,7 +17,8 @@ var monster = {
    else
    valueToUse = escape(value);
  • document.cookie = name + "=" + valueToUse + expires + "; path=" + path;
  • domain = domain ? "; domain=" + domain : '';
  • document.cookie = name + "=" + valueToUse + expires + "; path=" + path + domain;
    },
    get: function(name) {
    var nameEQ = name + "=",
@jgallen23
Copy link
Member

please submit a pull request with tests and I'll accept it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants