Application python reptile reptiles in the 16-cookie basis of

Cookie of reptiles Python application

What is Cookie

CookieSometimes use the plural form  Cookies, in English biscuits meaning. Refer to certain websites in order to identify the user's identity, a session tracking and data stored on the user's local terminal (usually encrypted). It is defined in RFC2109 and 2965 have been discarded, the latest specification is substituted RFC6265.

CookieThat is, by the server to the client's specific information, but this information in a text file stored on the client, and then each time the client sends a request to the server will bring these special information. Server received Cookielater will verify Cookiethe information in order to identify the user's identity.

CookieIt can be understood as a temporary pass.

 

What is the use Cookie

Since our HTTP protocol is stateless, so we have to realize the function of keeping state like landing on the site, then you need the help Cookie.

Each HTTP request after the data exchange is completed it will close the connection, so the next time an HTTP request can not let the server know your relationship with your last request. The use of Cookieafter your request after the first landing like successful, the server will be in Responsethe header information back to your Cookieinformation, the next time you visit Cookie time to bring this information, the server will be able to identify you as the a successful user login.

 

Cookie Content

CookieThe general format is saved json format, by a number of attributes.

  • name: CookieThe name

  • value: Cookiethe value of

  • domain: You can use this Cookiedomain

  • path: You can use this Cookiepage path

  • expires / Max-Age: This Cookietimeout

  • secure: it can only be provided by transmitting the entry httpsCookie

domain properties

The domain generally divided into top-level domain, two domain names, three domain names, and so on.

For example baidu.com is a top-level domain, and www.baidu.com and map.baidu.com is the second-level domain, and so on.

In our Cookieterms, there is a domainproperty that limits what you can use this one when domain names Cookie. Because each site will basically distribute Cookie, so the domainproperty can make when we visit will not bring Baidu Sina distributed to us Cookie.

In the same domain name system, the top-level domain is unable to use its secondary domain name Cookie, that access is not the time to bring baidu.com map.baidu.com distribution Cookie, and between the two domain names Cookiealso not be shared. But when the two domain names that can be used to access top-level domains Cookieare.

path attribute

path attribute can access the page path to this cookie. For example, domain is abc.com, path is / test, then only pages under / test paths can read this cookie.

expires / Max-Age attribute

Field set for this cookie timeout. If a value of a set time, then when this time is reached, this cookie failure. If not set the default value of Session, which means failure with the cookie and session. When the browser is closed (not the browser tab, but the entire browser), the failure of this cookie.

 

Cookie reptiles application

  1. In any way, such as browser, selenium, packets, etc., to obtain the correspondingCookie

  2. The Cookiesave can be saved to memory, files, database

  3. I want to use in the Cookieproject, from the preservation of places out Cookieperform application

 

 

PS

我们所说的使用Cookie进行实现登陆,都是需要服务端支持的,也就是说服务器给我们的Cookie有一个时间段的生命周期,这样我们保存下来的cookie才能在下次继续使用。

而有一些安全要求较高的网站,例如银行网站。是不支持cookie登陆的。

Guess you like

Origin www.cnblogs.com/winfun/p/10985579.html