Click here to Skip to main content
15,907,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I want to pass data between webpages with cookie. But the max capacity for cookie is almost 4000 bytes.
However my data is more than that limitation, and i do not know the exact size of data.it can be different from time to time.
How can i solve it?
Also i can not use session.
Thanks in advanced.
Posted
Updated 24-Jul-13 2:04am
v3
Comments
bbirajdar 24-Jul-13 7:19am    
Use two cookies

I would recommend using a database. Just pass the id to some records that the other page can then look up.

Or, as aspnet mentioned, use multiple cookies but with this much data I would suggest sticking to a db and passing just the ID.
 
Share this answer
 
Yes ryanb is right, what is the data you want to get search according to id or else use the multiple cookies if the size of the data is more then 4000 bytes.
 
Share this answer
 
Programming is a problem solving activity. You can't break the size limit, so you have to work around it, in no particular order you could:


  • Try compressing the data
  • Split the data across several cookies, you'll need to define the order you have done this in (aspnet -i's idea)
  • Store the data in a backing store (such as a DB) against a key, and send the key in the cookie (ryan's idea)


You'll need to decide which suits your needs: option 1 is only good if the data compresses well and/or is only a little over the limit in a way that guarantees the compressed value will be under the limit. The second option might have the problem that you end up sending lots of data & cookies (depending on the size of the information). The final option introduces an overhead, and you need to worry about setting up the backing store. Both the first and last options reduce/remove the ability of JavaScript to access the cookie data, the middle option would depend on how you split the data up.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900