Understanding session and cookie in django

I now have a user login program 

When the user visits login.html, after entering the user name and password to log in, the server will return a response to the requested browser, and there will be a Set-Cookie in the response header

The sessionid is recorded, and the value of the sessionid is stored in cooki. There are also information such as expiration time in Set-Cookie.

The browser will send this data to the server for each request. After the server receives the sessionid, it will find out the requester's Session based on this value.

The following figure is the request header when the browser visits index.html again, in which the browser sends a cookie to the server, and the cookie contains the sessionid

 

The session in this project is stored in the database, 

 When storing the Session, the key is the same as the sessionid in the Cookie, and the value is the key-value pair information set by the developer, encoded with base64, and the expiration time is set by the developer.

https://blog.csdn.net/qq_38059635/article/details/82972861

https://www.cnblogs.com/open-yang/p/11222459.html

Guess you like

Origin blog.csdn.net/weixin_48154829/article/details/107871206