question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cookie.java Removing a leading dot from cookie domain makes it unable to be used for subdomains

See original GitHub issue

https://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:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
metalurguscommented, Nov 16, 2016

then it themes like Android SDK bug. I’ve opened this issue because I was trying to use JavaNetCookieJar, with a default CookieManager. And it will not use cookies for foo.example.com, if cookie domain was originally .example.com

1reaction
swankjessecommented, Nov 16, 2016

The specs were revised and the leading dot was dropped as a feature. Today cookies whose domain is example.com will domain match foo.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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found