Verify Cookie Max Size

[Total: 0    Average: 0/5]

Max cookie size exposed.

Body Code:

<script src="http://www.js-examples.com/bin/cookies.js"></script>
<script>
var MAX=4004; // making this 4005 will mean it will not be stored off... (too big)
var myCookie = new Cookie(document,"a",0); // non persistent cookie
if (!myCookie.read() || !myCookie.a)
{
  // it does not exist yet - create it and stuff it full.
  myCookie.a = "";
  for (var i=0;i<MAX;i++)
  {
    myCookie.a += (i%10).toString();
  }
  myCookie.write();
  document.write("<BR>Cookie created and stored.<BR>");
}
else
{
  // show the cookie's data
  document.write("Length="+myCookie.a.length+"<BR>");
  document.write(myCookie.a);
  myCookie.del();
  document.write("<BR>Cookie deleted.");
}
</script>
<BR>
<a href="javascript:document.location=document.location;">reload this page</a>

Times Viewed: 9

Leave a Reply

Your email address will not be published. Required fields are marked *