View Full Version : Restricted number of Cookies in IE7
01-30-2007, 09:00 PM
Has anyone come across a restricted number of cookies in IE7.
I have several pages that ll write cookies, then on the final page all the cookies are displayed, it works in FF but not IE7.
With IE7 if I write 20 cookies then access them they are all present and correct. If I then write a another cookie, then one of the previous 20 cookies is lost and overwritten. If I print out all cookies for localhost there are only ever 20, never any more no matter how many I try and create.
Whats going on?
01-30-2007, 09:07 PM
It looks like you are correctliy. Google found this for me
01-30-2007, 09:16 PM
Thanks for that, guess I'll have to re-think my elements of my site. Damn IE7!
01-30-2007, 09:46 PM
Browsers are only supposed to keep the last 20 cookies set by a given site so IE7 is behaving correctly in that regard. Having other browsers not complying with the standards by keeping more cookies from a site than they are supposed to can lead to other problems especially if they comply with the maximum nunber of cookies overall that they are supposed to keep.
The only browser I know of that doesn't follow the cookie rules properly is IE6 which only allows a site to store 4k of data in total across the 20 cookies instead of allowing them to store 4k each.
Once you try to store a 21st cookie for a site or the 300th cookie overall the least recently referenced cookie will be deleted and replaced by the new one being set. It is possible that the cookie that is cleaned up when the 300 cookie limit is reached could be from the same site as the new one you are setting if it was set some time ago so you can only rely onn being able to reach 20 cookies if you set them all during the same visit.
01-30-2007, 11:06 PM
Based on what felgall is saying, it sounds like it would be better to have only one cookie per domain and manage it yourself. So instead of having cookies with values like
cookie 1 - "pizza"
cookie 2 - "large"
cookie 3 - "extra pepperoni"
cookie 1 - "c1=pizza&c2=large&c3=extra pepperoni"
cookie 2 - undeclared
cookie 3 - undeclared
Something like that. That way you keep the total number of cookies down and if you lose one value you lose them all so you are less likely to get some odd effects where only half the cookies are still there.
01-31-2007, 02:58 AM
Since IE6 limits you to 4096 bytes of data per site rather than per cookie the use of multiple cookies on the same site is not as useful as it could be.
Simplest use of a cookie is to just store a unique id in the cookie and store everything else in a database on the server. Then you read the cookie and lookup the database to find as much info as you needed to store all nicely arranged into separate fields. It keeps the information to be stored in the cookie to a minimum and avoids any privacy concerns relating to the content of the cookie.
01-31-2007, 02:57 PM
Thanks for the info, I have done what David_KW mentioned and stored more than one piece of info in a cookie, this has taken the total number below 20.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.