In a distributed system, session failure occurs during cross-origin access of subdomains, resulting in logon failure.
For example, if a user successfully logs on to www.111cn.net but fails to switch to its personalized domain name mb.111cn.net, the session fails.
What should I do?
You can use the session replication scheme, such as nfs session sharing, membercache session storage, and terracotta.
The above solutions can be used, but the above solutions will lead to a complicated development environment and an O & M environment, and slow session response across networks.
Therefore, we have used a lightweight cookie to replace the session solution.
The Cookie replaces the Session and solves the problem of distributed Session failure as follows:
Stored Procedure:
1. Convert the javabean to be saved to a json string (using the gson tool)
2. des encrypted json string
3. Set it to the cookie of the root domain name
Cookie. setDomain ("kaihuangzhe.com ");
Resolution process:
1. Traverse all cookies
2. Find the corresponding cookie
3. des decrypts the json string
4. Restore to javabean (gson ).