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