Flask: Flask technology used in the session

1, the session cookie and session technology

(1)cookie

  In the website, HTTP requests are stateless. In other words, even after the user first accesses the server and login is successful, a second request to the server still does not know the current request is initiated by which user. cookie appears to solve this problem, for the first time after the login server returns some data ( cookie ) to the browser, the browser will store that data locally. When the user initiates a second request, the browser will automatically get the last request of cookie data carried to the server, these cookie data will be able to tell which is currently initiating the request of the user. cookie amount of data stored is limited, different browsers have different storage sizes, but generally not more than 4K , so use cookie can only store some small amount of data.

(2)session

  session and cookie role somewhat similar, is to store the user information about it. The difference is, the cookie is stored in the local browser, the session is stored on the server. Data stored on the server will be more secure, not easily stolen. But stored on the server also has some drawbacks, it is to take up server resources.

(3) cookie and the combined use of session

  web development development so far, the cookie and session usage there have been some very mature program. In today's market and enterprise, there are two storage methods:

  • Stored in a server: The cookie storage session_id , specific data is then stored in the session in. When the user has logged in, the browser will be the cookie stored in a session_id , next time again requested, it will session_id carry up, according to the server session_id in the session to obtain the user's library session data, which can identify the user's identity, as well as It has been previously saved state information. This jargon is called the server side session
  • The S ession data encryption, and then stored in a cookie in. Such terminology is called client side session, flask is used in this embodiment, but may be replaced by other forms of

Guess you like

Origin www.cnblogs.com/xmcwm/p/11804775.html