While on a page on subdomain.foo.com, I know it is possible to set a cookie in JavaScript with a domain=foo.com clause (or domain=.foo.com according to earlier specifications), and have that cookie apply to all subdomains.
When I open up the developer console in Chrome on a GitHub Pages page (say, yelp.github.io) and try this using a domain=github.io clause, the cookie doesn't get set (document.cookie yields the empty string). I only seem to be able to get the cookie to set if I omit the domain clause, or use domain=yelp.github.io.
I can understand why GitHub would want to restrict cookie scope this way for security reasons, but I'm not sure how this is actually working or what's behind the behavior I'm seeing. Is there something special about the github.io domain? Is there a security policy being applied I'm not aware of? Or am I just doing it wrong?
document.cookie = 'foo=1; domain=github.io'