The phenomenon of

In the process of browsing websites, some websites need to be logged in before they can be accessed, and they will not be required to log in after logging in for several times, but sometimes they will be required to log in again after a period of time.

There are also some websites, in the browser on the automatic login, and a long time will not be invalid, this is because of what?

Front: static and dynamic pages

  • Static page: The content is fixed and cannot be generated differently based on the parameters
  • Dynamic pages: Data changes that can be handled flexibly according to requirements.

HTTP stateless

Stateless means that THE HTTP protocol has no memory for transactions and does not know how to distinguish between clients (state, user id, etc.). In this case, sessions and cookies can be used as a technical solution for connection state. Session is stored on the server to save user information, while Cookie is stored on the client, which can be the browser. After Cookie is provided, the network request can carry Cookie to the server, through which the server can distinguish users.

In crawlers, there are some pages that require login to access. Cookies from successful login are usually placed at the top of the request, so that there is no need to log in again.

What fields are included in the structure of Cookies

Session cookies and persistent cookies

A common misconception: Session is close the browser and disappear?

  • Common sense: : will remain until the server deleted.
  • Practical cause: Most of the stored cookies are session cookies. If a request is initiated without cookies, the session is considered invalid
  • In addition, because the session does not disappear, it is necessary to set the expiration time for the session. When the expiration time is reached, the session can be deleted to save storage space.