Using a note point in a cookie in Java code

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.