Give a cookie a domain name .example.com(pay attention to the leading point). Thus, a cookie is accessible under any subdomain. If you are going to share HttpSessionbetween subdomains, you can also simply configure the application server for this. It is best to refer to your documentation for details. In the case of, for example, Tomcat, just set the attribute emptySessionPath <Connector>to true:
<Connector emptySessionPath="true">
source
share