How to set cookies for a subdomain from the main domain?

Hello.
The website learn.javascript.ru written in the parameter "domain" to specify either the primary domain or its subdomain, but I can't create a cookie for one.example.com with the website example.com. About the point before domain know. Interested in making cookies to a single subdomain, while on the main domain.
Sample code
var date = new Date(new Date().getTime() + 60 * 1000);
document.cookie = "name=value; domain=learn.javascript.ru; path=/; expires=" + date.toUTCString();
June 10th 19 at 15:33
3 answers
June 10th 19 at 15:35
Solution
Ask cook for one subdomain from the primary domain is impossible. You can only create shared cookie for all subdomains and main domain, specifying the domain parameter domain of the website.
A more detailed answer received here
June 10th 19 at 15:37
path=one.domen.com
June 10th 19 at 15:39
I recommend to work with cookies good mini library.
When you work with it to solve
cookies({ cookieKey: 'value' }, { domain: 'sub.example.com' });

Find more questions by tags HTTP CookiesJavaScript