HTTP Brower Server | Cookie & Session

This blog is used to analyze and compare Session and Cookie, and pay tribute to the great man.
Cookie
Cookie Cookies are data stored on the local computer by a specific browser according to the user’s online behavior. The maximum size is 4k. For example, the browser user login account and password. When the user sends a request to some website servers, it will bring the cookie in Part of the information, the purpose is to enable the server to identify the request comes from a specific user, to solve the stateless drawbacks of the HTTP protocol.

Session
Session (session) is the user information data stored on the server side, the size of the data is not limited, the Session has an identifier SessionId is stored in the user's Cookie, when the user requests for the first time, it will be sent to a specific website server Random allocation (GUID), in subsequent user requests, the SessionId will be sent to the server, and the server will query the data stored on the server based on the SessionId, and then determine the specific behavior of the user.

Summary
it can be said, Session is like a present in the server-side Cookie, this thing is in line with the principle of symmetry, the server enhances the Cookie feature questions that if the browser is disabled Cookie how to do? ASP.NET provides a way for URL rewriting to place SessionId in the URL. The general process is that the first user request does not have a sessionId, then the server returns the data containing SessionId, which can be stored in the Hidden Fields of the form, which can guide the browser to save it in a local file, and the server helps to establish a new cookie data.

Question link
1. If the browser disables cookies, what should I do to achieve the same thing?
There is a method of JSP in java, response.encodeUrl("FormerUrl"). This method can intelligently determine whether the browser has disabled cookies, and if disabled, add SessionId to each URL request.
In .NET, I think it should be added in the routing. The JSP approach does not conform to the AOP idea, or I can encapsulate a class by myself and handle all URL requests centrally here. Haha, this seems to be the middleware idea in NET Core. Many processing components can be added before and after request processing.

Written in the last
Thanks for reading visit.

Guess you like

Origin blog.csdn.net/qq_37040173/article/details/81867209