Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can One Domain Have Multiple Cookies?

Tags:

http

cookies

Can one domain generate multiple cookies on visitor's web browser? If so, when user vists the website, which cookies will be delivered to server? And why would a website generate multiple cookies?

I checked my Google Chrome Browser's Cookies settings, found that there are multiple cookies of nytimes.com.

If server wants to store multiple key/value pairs in cookies, can't they be stored in the same cookies?

multiple cookies

cookies-1

cookies-2

like image 485
ninikin Avatar asked Jul 15 '09 14:07

ninikin


People also ask

How many cookies can a domain have?

To be safe, it's best to stick with 30 to 50 maximum cookies per domain.

Can I have 2 cookies with same name?

If multiple cookies of the same name match a given request URI, one is chosen by the browser. The more specific the path, the higher the precedence. However precedence based on other attributes, including the domain, is unspecified, and may vary between browsers.

How many cookies we can store per server domain?

If you want to support most browsers, then do not exceed 50 cookies per domain, and 4093 bytes per domain. That is, the size of all cookies should not exceed 4093 bytes. Cookies are sent on every request for a domain, this includes images.

Can a user have multiple cookies?

Data size limited by browsers (typically < 4 KB). A server can define multiple cookies with different names, but browsers limit the number of cookies per server (around 50).


2 Answers

Yes :)

I would speculate that the cookies were created by separate components of the website, which were created by separate teams of developers. We, of all people, should realize that this is often the case when we need to get some development done but do not have time to wait for collaboration or for another team to develop a necessary layer for us.

From wikipedia:

Relevant count of maximum stored cookies per domain for the major browsers are:

  • Firefox 3.0: 50
  • Opera 9: 30
  • Internet Explorer 7: 50
like image 102
JoshJordan Avatar answered Oct 30 '22 08:10

JoshJordan


Can one domain generate multiple cookies on visitor's web browser?

Yes. The exact limit depends on the browser, Internet Explorer used to accept 20 but increased this to 50.

If so, when user vists the website, which cookies will be delivered to server?

All of them

And why would a website generate multiple cookies?

So that you don't need to serialise all the data (which could be from unrelated parts of the system) in one cookie.

like image 28
Quentin Avatar answered Oct 30 '22 10:10

Quentin