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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

maximum cookies

Status
Not open for further replies.

Jeremy21b

Technical User
Jul 7, 2002
127
CA
Apparently most web browsers have a limit of 20 cookie values per domain name. We are redesigning our website and wanted to switch to using more cookies than session variables. Is there any way to use more than the maximum 20 values (like setting a cookie to a different domain name or something)?

Also, how does the browser determine which cookie value to replace if a domain exceeds 20 values? Is it just FIFO (First In First Out)? Is there any way to lock a cookie value or prevent it from being overwritten? If it is FIFO, I might have to reset that saved cookie in any code that might potentially overwrite that value.
 
it's not 20 cookie values per domain it's 20 cookies.

there can be theoretically unlimited values per cookie upto the 4k limit.
thread333-884588



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Are you sure there are unlimited values? As I was working on our new website design, cookie data was being dropped as new data was stored in cookies. The longest cookie value was maybe 30 characters and there were no more than 25 - 30 cookie values. Are you sure of the definition of cookies....file instance vs individual cookie value?
 
I'm reading up on cookies on msdn:

Where they refer to 'cookie', they mean the individual values, like id=1. So I'm pretty sure it is really 20 maximum values within the cookie.

Cookie file names are normally automatically generated like username@domain.com. So I don't see how you could really create 20 separate cookie files.
 
You can effectively store more than 20 values, though, by storing multiple things within one value, stuff that you parse out later.
 
This code will create a cookie called logon with 2 values in it name & active

response.cookies("logon")("name") = UserName
response.cookies("logon")("active") = true

This code will create another cookie called info for the same domain with 2 values.
response.cookies("info")("colour") = Blue
response.cookies("info")("highlight") = Yellow

also it's not just the value length that takes up space, there is the ident data and attribute data as well.

I've never tested this to the limit but never had any problems either.




Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Thank you for confirming that 20 values thing Genimuse. Again you came through for me.
 
hmmm sub cookies.....interesting...I might have to test that to see if it still counts it as 1 cookie each.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top