Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookies lost problem

Status
Not open for further replies.

jb13

Programmer
Oct 12, 2006
11
CA
Hi,

at first sight, writing cookies with javascript seem easy, but in practice i got a weird bug.

In fact, cookies are correctly saved on client computer, but for some reason, when the number of cookies i wrote reach 18 (why 18 i really don't know, it is not always the same number), the next cookie i'll write will overwrite another i wrote before, even if the cookies have diffrent names.

As a result i lost some of the values i stored in theses cookies, and the ASP Session ID cookie isn't different, it is overwrited by another cookie with a totally diffrent name, why ??

Can anyone help me on that problem ?
It doesn't happen if i wrote my cookies using server side instruction (ASP), but in this case i most write the cookie with client-side code.

Thank you for your help
Jonathan
 
MSDN said:
Microsoft Internet Explorer complies with the following RFC 2109 recommended minimum limitations:
• at least 300 cookies
• at least 4096 bytes per cookie (as measured by the size of the characters that comprise the cookie non-terminal in the syntax description of the Set-Cookie header)
• at least 20 cookies per unique host or domain name
Note These recommended minimum limitations appear in RFC 2109, section 6.3, "Implementation Limits." For more information, see the "References" section.

Are you sure it's only 18 and not 20?

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Yea it's probably 20, but shouldn't i get the same problem if i write my cookies using vbscript on server-side ? Because i don't.

If I only write one cookie that contains all the values like "var1=val1&var2=val2&var3=val3..." that will work ? As long as I don't store 4k of data, which is more then i need anyway.

 
Yes, you should get the same problem when you write cookies on the server side. However, "writing" cookies on the server side doesn't do anything right away, all it does it create a SetCookie header for the document. It isn't until that document is sent to the browser that the cookies are actually created. That might have something to do with the difference.

Yes, concatenating the values into a single cookie would be the easiest solution to the problem.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top