Why web browser don't care about port number when sending cookie?
cookies, http
Solution
This is answered by https://stackoverflow.com/a/4212964/14731 and by the author of RFC 6265:
If we were designing cookies today, we'd definitely make it per-port. However, cookies are widely used on the Internet today and making this sort of change would break too many sites. For the most part, cookies are "done" in the sense that I wouldn't expect them to change much. Unfortunately, that means we stuck with cookies not respecting port number.
Source: https://groups.google.com/d/msg/comp.infosystems.www.misc/6WXdQ2RFhG8/VvOUuR3FNAUJ
Problem
I have manually created two cookies using firebug: ``` Cookie1=value1; expires=Sat, 29 Mar 2014 06:21:54 GMT; path=/Ex05Cookie; domain=localhost; HttpOnly Cookie2=value2; expires=Sat, 29 Mar 2014 06:21:54 GMT; path=/Ex05Cookie; domain=localhost:8080; HttpOnly ``` The only difference is the domain attribute, one is `localhost` while the other has a port number. This is the HTTP header when I try to request `http://localhost:8080/Ex05Cookie/`: ``` GET /Ex05Cookie/ HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Cookie: Cookie1=value1 Connection: keep-alive Cache-Control: max-age=0 ``` where the header only contains Cookie1 whose domain is `localhost`. Why my firefox don't send Cookie2 instead of Cookie1?