Javascript cookie limit

Asked

Viewed 88 times

2

I have a javascript code that loads cookies into an html page. Every 15 seconds a function is activated, and this saves new information in 5 cookies, and makes the LOAD of 5 cookies for variables. The question is is is there a limit of cookies saved for time? Because 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 carry 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"); */
  • 1

    The limit will never be this low. Can you reproduce the problem in jsFiddle? the cookie has an expiration date expires=date;, you can show how you are using the cookie?

  • Could be another problem, this is WEB or a hybrid App?

  • it’s web, I’m just using javascript, html and css

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.