Skip to content

Instantly share code, notes, and snippets.

@dungsaga
Last active February 5, 2016 08:43
Show Gist options
  • Save dungsaga/559fa65c934b8615a59f to your computer and use it in GitHub Desktop.
Save dungsaga/559fa65c934b8615a59f to your computer and use it in GitHub Desktop.
reproduce bug "document.cookie is empty if any cookie has non-ASCII characters" (https://code.google.com/p/chromium/issues/detail?id=485035)
@dungsaga
Copy link
Author

This error still happens in Chrome 46 & Chrome 47

@dungsaga
Copy link
Author

document.cookie return an empty string, but Chrome DevTools still show cookies as usual
==> maybe the invalid cookie cannot be parsed as UTF-8 string, and Chrome aborts the parsing of cookies

@dungsaga
Copy link
Author

As Nicholas Zakas explained (https://www.nczonline.net/blog/2009/05/05/http-cookies-explained/), cookie spec is not clear enough and cookie encoding is not specified since its beginning.
Each browser has a slightly different implementation. In this case, Google Chrome has a bug that it reports no cookie exists if any cookie has an incorrect UTF-8 encoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment