In my project I have two large datatables which save its state in cookies. Average size of data to store is about 1500-2000 bytes. Saving state of one table cause cookie expiration of another due to 4 KiB limit. In current implementation, old cookies are expired in order of creation time. I think that it is necessary to expire cookie of current table at first if exists.
Here is a path.
Here is a path.
@@ -4517,6 +4517,7 @@ if ( iNewCookieLen+document.cookie.length+10 > 4096 ) /* Magic 10 for padding */ { + var equalCookieIdx = -1; for ( var i=0, iLen=aCookies.length ; i<iLen ; i++ ) { if ( aCookies[i].indexOf( sBaseName ) != -1 ) @@ -4532,10 +4533,28 "name": aSplitCookie[0], "time": oData.iCreate } ); + + var cookieName = aSplitCookie[0]; + while (cookieName.charAt(0)==' ') + { + cookieName = cookieName.substring(1, cookieName.length); + } + if (cookieName == sNameFile) + { + equalCookieIdx = aOldCookies.length - 1; + } } } catch( e ) {} - } + } + } + // At first delete cookie with equal name if exists + if ( equalCookieIdx >= 0 ) + { + var old = aOldCookies[equalCookieIdx]; + document.cookie = old.name+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path="+ + aParts.join('/') + "/"; + aOldCookies.splice(equalCookieIdx, 0); } // Make sure we delete the oldest ones first