Some basic points of cookies:
The cookies obtained in Java come from the HttpServletRequest information submitted by the user, and the cookie itself is stored in the user's local, and when we write cookies, we use HttpServletResponse to write cookies.
We often delete cookies when we find that the deleted data can be obtained when we first use httpservletrequest, but we can't get it from the second time. This strange phenomenon may many people have encountered, perhaps some people have not encountered in a lifetime, because this phenomenon exists only a specific scenario, the scene is as follows:
1. The user initiates the request
2. The server obtains the user request, obtains a key value in the cookie like a
3. The server uses HttpServletResponse to remove the key value a
4. When the server gets the key value a again, the key value A is found to have data.
In this case, we basically obviously see the problem, because we use httpservletresponse Delete key value A, delete the user browser local key value A, However, the HttpServletRequest saved cookie information in this user-initiated request is not changed or the cookie state before the deletion, so the fourth step to get key value A is still available. This is the state that often occurs when the cookie is deleted but the first time it still has a value.