Cookie.java Removing a leading dot from cookie domain makes it unable to be used for subdomains
See original GitHub issuehttps://github.com/square/okhttp/blob/59e70dad8193ad5f8cd79749fc00be7dcf0308d1/okhttp/src/main/java/okhttp3/Cookie.java#L421
On this line the leading dot of the cookie domain is removed permanently, and we are unable to see if the cookie should be used on subdomains.
Example:
I perform a request for www.site.com/login
. In response it returns me Set-Cookie
with domain=.site.com
.
After parsing, cookie is stored with a domain site.com
, which makes it non-usable even for www.site.com
AFAIK, it does not match cookie specification.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Cookie Domain contains Dot? - java - Stack Overflow
When the cookie has domain: .mydomain.com I tried Cookies.removeCookie("cookieName", "/") but still I cannot remove the cookie. It must be ...
Read more >Leading Dots On HTTP Cookie Domains Ignored - Ben Nadel
Ben Nadel demonstrates that the leading dot in an HTTP cookie domain is ignored (which is what the MDN documentation taught him).
Read more >Working With Cookies and Creating Cookies in JavaScript
In RFC 2109, a domain without a leading dot meant that it could not be used on subdomains, and only a leading dot...
Read more >Can subdomain.example.com set a cookie that can be read by ...
example.com will have the leading dot ignored (section 5.2. 3), and the cookie will then be sent to the naked domain and to...
Read more >Cookies, document.cookie - The Modern JavaScript Tutorial
A domain defines where the cookie is accessible. In practice though, there are limitations. We can't set any domain. There's no way to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
then it themes like Android SDK bug. I’ve opened this issue because I was trying to use
JavaNetCookieJar
, with a defaultCookieManager
. And it will not use cookies forfoo.example.com
, if cookie domain was originally.example.com
The specs were revised and the leading dot was dropped as a feature. Today cookies whose domain is
example.com
will domain matchfoo.example.com
dot or no dot. https://tools.ietf.org/html/rfc6265#section-4.1.2.3 https://tools.ietf.org/html/rfc6265#section-5.1.3