user1432124
user1432124

Reputation:

How to store 1MB data in a cookie?

I am trying to store 1000KB (~1MB) of data in a cookie in JavasSript but it is not working.

How can I do this?

Upvotes: 0

Views: 395

Answers (3)

austincheney
austincheney

Reputation: 1115

Instead of a cookie use localStorage.

https://developer.mozilla.org/en/DOM/Storage

http://en.wikipedia.org/wiki/Web_Storage

Most browsers allow 5mb per domain, but IE will give you 10mb per domain.

Upvotes: 0

Don't do that. Sending a megabyte of data takes a lot of time (often more than a second). Keep some session status hidden inside your server. Then your cookie string is just a small opaque identifier which should be keyed by the server.

Upvotes: 2

JeremyWeir
JeremyWeir

Reputation: 24378

For IE, and I'm sure most other browsers, the limit is around 4K

For one domain name, each cookie is limited to 4,096 bytes

http://support.microsoft.com/kb/306070

Upvotes: 0

Related Questions