1

Please,

I don't know upgrading one existing cookie. I tryed with the code in below but don't worked. He isn't upgrading array length but $.listImages.length return correct number.

My Jquery version is 1.12.

var list = [];
  for (var i = 12; i >= 0; i--) {          
    var image = {
      id:"f6183197-7925-45a8-bafb-7e13c69686a9",
      name:"CACHOEIRO WHITE 2CM Block 01000775 Bundle  Slab 005",
      path:"FOTOS - 2016\\02 - FEVEREIRO\\CACHOEIRO WHITE\\CACHOEIRO WHITE01000775-2CM\\",
      thumbnail:null,
      dateIndex:"2016-04-28T14:42:39",
      file:"CACHOEIRO WHITE 2CM Block 01000775 Bundle  Slab 005.JPG"
    };
    list.push(image);
  }
  Cookies.set('imagesSelected', list);
  var listSaved = Cookies.get('imagesSelected');
  //Returned number 13?
  alert(listSaved);

  //Save and get again but new quantity

  list = listSaved;
  for (var i = 3; i >= 0; i--) {          
    var image = {
      id:"f6183197-7925-45a8-bafb-7e13c69686a9",
      name:"CACHOEIRO WHITE 2CM Block 01000775 Bundle  Slab 005",
      path:"FOTOS - 2016\\02 - FEVEREIRO\\CACHOEIRO WHITE\\CACHOEIRO WHITE01000775-2CM\\",
      thumbnail:null,
      dateIndex:"2016-04-28T14:42:39",
      file:"CACHOEIRO WHITE 2CM Block 01000775 Bundle  Slab 005.JPG"
    };
    list.push(image);
  }
  listJSON = JSON.stringify(list);
  Cookies.set('imagesSelected', listJSON);
  listSaved = Cookies.getJSON('imagesSelected');
  //Returned number 16?
  alert(listSaved.length);
  • That is working, see https://jsfiddle.net/r0odz1jv/. Need to provide the version it is being used, the error and the content of the `$.listImages` property. Also, this could be a problem: http://stackoverflow.com/questions/335244/why-does-chrome-ignore-local-jquery-cookies/347997#347997 – Fagner Brack May 07 '16 at 02:17
  • Oh... I am in local mode but using Iceweasel. I will test in hosted mode. – Roger Correa May 07 '16 at 02:36
  • Same problem. It's very weird. I record an array with 14 items and when I call get returns only 9. – Roger Correa May 07 '16 at 02:57
  • Am I reaching the size limit for cookies? I'm trying to write almost 3400 characters. – Roger Correa May 07 '16 at 03:05
  • It could be. One should not send big chunks of data using the cookie, it should only send small tokens and pieces of information. – Fagner Brack May 07 '16 at 03:14
  • I think it was the same character limit. I solved my problem using StorageAPI. https://github.com/julien-maurel/jQuery-Storage-API – Roger Correa May 07 '16 at 03:21
  • Yes, I know that not is possible send big data in the cookies but the major problem was didn't any exception return. It was hard to find out. – Roger Correa May 07 '16 at 03:29
  • Thanks, @FagnerBrack! – Roger Correa May 07 '16 at 03:30
  • We have plans to add a tool to debug the cookies in the page, see the bullet points of https://github.com/js-cookie/js-cookie/issues/57 – Fagner Brack May 07 '16 at 08:50

1 Answers1

1

I think it was the same character limit. I solved my problem using StorageAPI. github.com/julien-maurel/jQuery-Storage-API

Not is possible send big data in the cookies but the major problem was didn't any exception return. It was hard to find out.