2

My App sets different configuration related parameters, token etc to browser cookie. This was working fine with angular-cookie version 1.2.6. But now when I tried to upgrade my angular-cookie version to 1.5.11, suddenly I have started getting error:

Cookie length should be less then or equal to 4096 characters.

Is there any restriction imposed in latest version of angular-cookie? If yes how can I get over to this?

There are several questions on SO, related to this but no one seems to be having solution. Can anyone please help me here.

undefined
  • 3,464
  • 11
  • 48
  • 90
  • Actually this restriction is a standard: "cookies are usually limited to 4096 bytes and you can't store more than 20 cookies per site. " In my opinion instead of getting rid of this warning, you may thing to limit your cookie's length to 4096 – quirimmo May 18 '17 at 09:21
  • i am surrprised, then how this works with angular-cookies version 1.2.6? – undefined May 18 '17 at 09:34
  • This is a really good question :) No idea about that support, but keep in mind that the 4096 is for all the cookies payloads, not only the values, but also expiration dates and names for example. So you should not exceed this value including all. Try to take a look to this website too and try to run the test: http://browsercookielimits.squawky.net/ – quirimmo May 18 '17 at 09:48
  • Maybe that's the reason of this change with the new version of angular-cookie: "Up until AngularJS 1.3, $cookies exposed properties that represented the current browser cookie values. In version 1.4, this behavior has changed, and $cookies now provides a standard api of getters, setters etc." https://docs.angularjs.org/api/ngCookies/service/$cookies If this is right, you should notice this error for all the versions greater than 1.3 – quirimmo May 18 '17 at 09:52
  • I don't know what are you storing, but perhaps you could think to switch to the local storage – quirimmo May 18 '17 at 09:57
  • @quirimmo I have a very big app, which is highly dependent on cookies, changing this to local storage will be very big task. So I was looking for an alternate way.. – undefined May 18 '17 at 10:57
  • maybe keep the older version of angular-cookie if it was not affected by that issue. Unfortunately I don't have anymore solutions at the moment and it seems that none does, considering no replies :D – quirimmo May 18 '17 at 12:28
  • Unfortunately I have to update angular 1.5.11 and angular-cookie 1.2 doesn't support with this version... :( – undefined May 18 '17 at 14:09

0 Answers0