Giter VIP home page Giter VIP logo

Comments (3)

dittodhole avatar dittodhole commented on May 17, 2024

the only eye-catcher are following lines:

if (value === null) {
    options.expires = -1;
}

could you maybe isolate your breaking-call to a fiddle (eg @ jsfiddle.net)?

from jquery-cookie.

bunnymatic avatar bunnymatic commented on May 17, 2024

I'm seeing similar behavior - Mac OSX - Chrome 18.0.1025.163

From the console:

/** set a cookie and check it **/
> $.cookie('blah',1);
> "blah=1"
> $.cookie('blah');
> "1"
/** looks good **/

/** set a cookie with a little more data and check it **/
> $.cookie('blah', JSON.stringify({abc:1}));
> "blah=%7B%22abc%22%3A1%7D"
> $.cookie('blah');
> "{"abc":1}"
/** looks good **/

/** set the same cookie with expires **/
> $.cookie('blah', JSON.stringify({abc:1}), {expires: 7});
> "blah=%7B%22abc%22%3A1%7D; expires=Fri, 27 Apr 2012 22:45:16 GMT"
> $.cookie('blah');
> null
/** no dice! **/

Any ideas what might be happening here?

from jquery-cookie.

bunnymatic avatar bunnymatic commented on May 17, 2024

It looks like i had an old version. The latest code (commit 1fa4a18) seems to do the trick. The old version i was using included the following extra bit for managing expiry. This was probably the issue:

if (typeof options.expires === 'object') {
  var days = options.expires.days || 0;
  var hrs = options.expires.hours || 0;
  var mins = options.expires.minutes || 0;
  var secs = options.expires.seconds || 0;
  t = options.expires = new Date();
  t.setDate(t.getDate() + days);
  t.setHours(t.getHours() + hrs);
  t.setMinutes(t.getMinutes() + mins);
  t.setSeconds(t.getSeconds() + secs);
}

I've added a couple tests for set/get cookies with expiry. I'll submit a pull request if you feel like adding that to the project.

Cheers
Mr Rogers

from jquery-cookie.

Related Issues (20)

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.