Setting Cookies to Subdomains in JavaScript

We've recently faced a problem of setting a cookie from to all subdomains in a * domain.

The solution seemed pretty straightforward: just set a wildcard cookie to (note that the first character is a dot). However, we had to determine the target domain (the actual value of “”) automatically because our code is fired on tens of thousands of different domains.

And here came the problem: the list of Top-Level Domains.

Continue reading →