Cookies limit javascript

2

I have a javascript code that loads cookies into an html page. Every 15 seconds a function is activated, and this SAVE new information in 5 cookies, and makes the LOAD of 5 cookies for various variables. The question is is there a limit on cookies saved by time? Well after 15 minutes running some cookie information seems to disappear.

The code to save the cookie I know is right, if it was wrong it would not load the complete information at any time:

static save(cname, cvalue, time) {
  if (cname == "salaXml")

    var d = new Date();

  d.setTime(d.getTime() + (time * 24 * 60 * 60 * 1000));

  var expires = "expires=" + d.toGMTString();
  var valor = cvalue;

  document.cookie = cname + "=" + valor + ";" + expires + ";path=/;";

}

static load(cname) {

  var name = cname + "=";
  var decodedCookie = decodeURIComponent(document.cookie);
  var ca = decodedCookie.split(';');
  var conteudoCookie = "";
  var regexNome = new RegExp(cname);

  for (var i = 0; i < ca.length; i++) {
    if (regexNome.test(ca[i])) {
      var conteudo = ca[i].trim();
      conteudoCookie += conteudo.substring(name.length, conteudo.length);

    }
  }

  return conteudoCookie;
}

/*exemplo: Cookie.save("user",valorAleatorio,2); Cookie.load("user"); */
    
asked by anonymous 14.06.2018 / 21:53

0 answers