After beating my head against a wall for three hours wondering why setPath() and setDomain() were just not working on my Cookie object…. I got a brainwave. Maybe it wasn’t that the core libraries were broken…. maybe my payload was dodgy. It did have newlines in it, but the object would handle that for me, right?

In retrospect I should have read the Javadoc ;-)

`

With Version 0 cookies, values should not contain white space, brackets, parentheses, equals signs, commas,double quotes, slashes, question marks, at signs, colons, and semicolons. Empty values may not behave the same way on all browsers.

`

In the end I just needed to do a myPayload.replace('n', ' '); to kill off the offending newline (which I guess just gets passed verbatim to Set-Header). I must be using v1 cookies, since it didn’t seem to mind about the space.

Anyways… a learning experience.