Java Learning----A brief summary of session and Cookie __java learning

Source: Internet
Author: User

Recently a simple study of the session and the difference between cookies, read a few blog posts, roughly the concept of wisp, here to make a summary, convenient memories and learning.

One. The principle of the session

We know that the HTTP protocol is stateless, that is, when the browser accesses the server's resources through the HTTP protocol, the HTTP protocol does not save the user's information, and does not save the context, then the session appears. Session is a mechanism for saving user information and context on the server side of the hey.

Cookies are the same mechanism and principle as sessions, but cookies are a mechanism for saving state on the client. In comparison, because the session is saved on the server side, so relatively safe, the session save the information is relatively perfect, because the cookie is in the storage size limit, it is generally important information are stored into the session.

Two. Sesssion and cookies in contact

They are contacted through SessionID, because each time the server is accessed, a SessionID is saved to the cookie until the next visit, and if there is a session in the session library, if so, The information is passed to the client, and if not, a new session is established.

Three. Classification of Cookies

Cookies are generally divided into session cookies and persistent cookies. Session cookies are typically kept in memory, and as the browser shuts down, the session cookie disappears; The persistent cookie is saved in the database or saved locally as a file.


The above is to read a few posts after a little summary, if there is a mistake, but also please correct me.


No Bujikuibu, no miles

Does not accumulate the small flow, does not have to become Jianghai

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.