Giter Club home page Giter Club logo

cookie-monster's Issues

setting objects as cookie value

When I try to set an object as a cookie value, it fails. Should I use JSON myself or are you planing to add support for this in the library?

Safari Not Setting Cookie

I have a standard Safari setup.
Cookies from my Rails application are setting properly.
Safari v 6.0.2
No errors in console.
Cookies are not being set.

Not sure what to look for or to help debug, but let me know and I'll try and get you whatever information you need.

Why "v"?

Simple question... Why did you use v (here)? Could you not just set the object without the v? Or is it in case you need to store other values? If so, you're not, so why?

Curious :)

can't use with ender

Can you actually use this with ender? It's tagged with ender however there's no actually additions to the ender object ($) that can be used. I don't see any integrations in the code either, or anyway at all how to use it.

Not an issue, a suggestion...

Now you have cookie time only in nr of days, you could enhance that a little.

The old "days" parameter is renamed to "period".. (it defaults back to the original days).

Now the period can be "4d" or "8h" or "1d4h" or "12" for just 12 days

    if (typeof period === "number") {
        period = period.toString()+"d"
    }
    if (typeof period === "string") {
        var addtime=0, t, i, reg = /([0-9]{1,3}[d|h])/g, arr = period.match(reg);
        for (i=0;i<arr.length;i++) {
            t=arr[i].slice(-1);
            switch(t) {
                case 'h':
                    addtime += (parseInt(arr[i]) * 60 * 60 * 1000)
                    break;
                case 'd':
                default:    
                    addtime += (parseInt(arr[i]) * 24 * 60 * 60 * 1000)
                    break;
            }
        }
      date.setTime(date.getTime() + addtime);
      expires = "; expires=" + date.toUTCString();
    }

Add domain parameter for the set function

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 + "=",

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.