当前位置:网站首页>[network planning] 2.2.3 user server interaction: cookies

[network planning] 2.2.3 user server interaction: cookies

2022-06-11 00:27:00 ChuHao H

 Insert picture description here
This article is based on 《 computer network —— top-down approach 》 A Book

Interaction between user and server :cookie

HTTP The server is stateless ( That is, the information of the client requesting the service is not recorded ), But sometimes Web The site wants to be able to identify users , To realize functions such as restricting user access and identifying user identity . So ,Web The site uses cookie technology ( Be careful :cookie Do not belong to HTTP agreement , He is supplementary HTTP Technologies that are not functional in some way )

cookie There are four components :

  1. stay HTTP One... Is reserved in the response message cookie Head office
  2. stay HTTP One... Is reserved in the request message cookie Head office
  3. One... Is reserved in the client system cookie file , And managed by the user's browser
  4. be located Web A management of the site cookie Back end total database

and cookie The function process of is as follows :

When a user first visits the site , The site will generate a unique identification code , And use this as an index to generate a table entry in the back-end database . And in response to the Set-cookie The first line sends the ID back to the client . After the customer receives the response message , Will be in Set-cookie The identification code in is stored in the... Of the client cookie In file . When the user continues to browse the website , One per request Web page , Its browser will query cookie File and extract her ID for the site , And put the identification code in HTTP Requesting a message Cookie In the first line .

If the user visits the site again after a week , His browser will send the corresponding cookie Put in request message header .

原网站

版权声明
本文为[ChuHao H]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020628372699.html