Home >Web Front-end >JS Tutorial >How to specify js to access cookies of other domain names_javascript skills
Similar to paths, host names refer to different hosts in the same domain. For example, www.sosuo8.com and blog.sosuo8.com are two different host names. By default, cookies created in one host cannot be accessed in another host, but they can be controlled through the domain parameter. The syntax format is:
document.cookie="name=value; domain=cookieDomain";
Take sosuo8 as an example. To achieve cross-host access, it can be rewritten as:
document.cookie="name=value;domain=.sosuo8.com";
In this way, all Hosts under sosuo8.com can access this cookie.