Crawler basics-sessions and cookies

What is a conversation?

Session: [ˈseʃ(ə)n] Session refers to the communication process between the browser client and the server (interactive system).
会话一旦建立就应当一直存在,直到用户空闲时间超过了某一个时间界限,容器才应当释放该会话资源。(l来自百度百科)For example, you have a VIP member of Youku, and you log in to the web to watch Country Love. For the first time, he doesn't know that you are a distinguished VIP, so you need to log in. You watched two episodes and didn't want to watch it. You closed the web page. Today you want to read it again, so you open the webpage and find that you are not allowed to know your identity when you log in. This is the role of the cookie. It is the cookie that maintains the session. The session is not because you closed the browser. It is closed. The duration of the session is determined by the max age in the cookie list. The cookie expires after mag age seconds. At this time, you need to log in again.
由于我的优酷会员过期了,所以我看了下自己的知乎cookie列表,天哪,要到2024才会过期?
The following is an explanation of the cookie ['kʊki] list (quoted from https://cuiqingcai.com/5487.html)

Name [neɪm]: The name of the cookie. Once created, the name cannot be changed.
Value ['vælju]: The value of the cookie. If the value is a Unicode character, it needs to be a character encoding. If the value is binary data, you need to use BASE64 encoding.
Domain [doʊ'meɪn]: The domain name that can access the cookie. For example, if it is set to .zhihu.com, all domain names ending in zhihu.com can access the cookie.
Max Age: The time when the cookie expires, in seconds. It is also often used with Expires, through which the effective time can be calculated. If Max Age is a positive number, the cookie will expire after Max Age seconds. If it is a negative number, the cookie will become invalid when the browser is closed, and the browser will not save the cookie in any form.
Path [pæθ]: The use path of the cookie. If it is set to /path/, only pages with the path /path/ can access the cookie. If set to /, all pages under this domain name can access the cookie.
Size [saɪz] field: the size of this cookie.
HTTP (H:[eɪtʃ]) field: the httponly attribute of Cookie. If this attribute is true, only the cookie information will be included in the HTTP header, and the cookie cannot be accessed through document.cookie.
Secure [sɪ'kjʊr]: Whether the cookie is only transmitted using a secure protocol. Security protocols include HTTPS and SSL, etc. The data is encrypted before data is transmitted on the network. The default is false.

Guess you like

Origin blog.csdn.net/weixin_47249161/article/details/113972608