7

I found that angularjs serializes and deserializes when using $cookieStore.put/get and I'm able to put a whole object into it. So what is the size limit? 4kb?

rjnpnigrhi
  • 79
  • 1
  • 7

1 Answers1

6

cookie size is 4kb. if your object less than that you will be capable to add the whole object. Just keep in mind that 4kb is for whole cookie including name, expiration and value. But cookie may not be appropriate place to store objects. Please consider to use html5 localStorage except cases when you 100% sure you want it to be in cookies.

Fedor Skrynnikov
  • 5,521
  • 4
  • 28
  • 32
  • Thanks for the info.. If I go on putting values inside it without "remove" then what will happen after the limit is over. I will get error messages or older cookies will be removed automatically. – rjnpnigrhi Feb 25 '14 at 08:54
  • Although, this is not the part of angular behavior, but completely depends on the browser. An old data might be truncated http://stackoverflow.com/questions/1595872/what-happens-when-cookies-file-exceeds-maximum-size – Fedor Skrynnikov Feb 25 '14 at 08:59
  • Thanks again.. I think this will be more appropriate for me.. http://gregpike.net/demos/angular-local-storage/demo/demo.html – rjnpnigrhi Feb 25 '14 at 09:11
  • Yes. LocalStorage, as I said, is the way to go for the most of cases when you need to store something. Your link is the angular way to work with localStorage – Fedor Skrynnikov Feb 25 '14 at 09:15