Cookies across paths and subdomains
When setting a cookie, it gets the current domain and path as default parameter. The problem there is, that the cookie won't be available in a subdomain. To be able to access it on the subdomain, you need to set the domain and path explicitly:
document.cookie = "theNumber=7,path=/;domain=yourdomain.tld";
Make sure that you also define the path when you delete the cookie, as it won't get deleted if you don't set it explicitly.