laitimes

Cookies and Session understand one, what is cookies: two, the role of cookies: three, when the cookie is generated: four, the life cycle of the cookie five, the disadvantages of cookies six, session understanding

<h1 class="pgc-h-arrow-right" data-track="1" ></h1>

Is a small piece of data that the server sends to the user's browser and saves locally, it will carry the data and send it to the server the next time the browser sends another request to the same server, and the server can determine which one the current user is through the data carried by the browser. Note: Cookies generally store a limited size of no more than 4 kb, so cookies can only store a small amount of data.

<h1 class="pgc-h-arrow-right" data-track="4" >2</h1>

Session state management

Personalization

Browser behavior tracking

<h1 class="pgc-h-arrow-right" data-track="11" >3</h1>

When the client sends a request to the server, the server sends a cookie to the client, and then the browser saves the cookie.

There are two ways to save cookies: one is that the browser saves the cookie in memory, and the other is: the client's hard disk

<h1 class="pgc-h-arrow-right" data-track="16" >4</h1>

When a cookie is produced, an Elevate value is specified, which is the cookie lifetime, during which the cookie value is valid and the excess period is cleared. Some pages set the lifetime of cookies to 0 or negative values, and when the browser is closed, the cookie is cleared immediately and the user information is not recorded, making it more secure.

<h1 class="pgc-h-arrow-right" data-track="19" >5</h1>

Quantity limit

Security cannot be guaranteed

The browser can disable the use of cookies

<h1 class="pgc-h-arrow-right" data-track="26" >6</h1>

. Sessions are used to store the properties and configuration information required for a particular user session.

. The cookie is the client-side record status, and the Session is the server-side record state

When the client sends a cookie, the server will find the sessionID from the cookie, and return the corresponding session information to the client to carry out the circulation of the user page. If you look up Session by sessionID and find that there is no Session, you will create a new Session.