As we all know. The Web application is generally based on the cookie ID to complete the session support for user tracking, the session between the top-level domain names such as a.com and www.a.com and cookies are not shared by default, This is because the cookie determines attribution based on the domain attribute. Through the Chrome browser's F12 debugging tool we can see that a.com's default domain is a.com and www.a.com's default domain is www.a.com, Perhaps they all visit the same site, but these two domain attribute values are inconsistent resulting in the a.com based on cookie and session login behavior cannot be obtained on www.a.com.
PHP can modify the domain name attribution of PHP SessionID by php.ini, and JSP can also complete the Jsessionid (default) domain property modification through the config file of Web. xml
Directly on the code:
<session-config>
<session-timeout>60</session-timeout>
<cookie-config>
<path>/</path>
<domain>.a.com</domain>
</cookie-config>
</session-config>
Insert this segment into Web. XML and redeploy the app. The domain attribute is changed to. com, the reason is not to repeat.
Jsp,javaweb master/two level domain session sharing by configuring Web. Xml