What is Sesson?
In short, it is a session-level cookie, plus a group of scattered lists in the server memory.
When you close your browser, the cookie disappears.
This cookie is stored in the browser cache instead of on the disk.
Session legends
It is said that sessions and Applications in Web applications are stored on the server, while cookies are stored on the client.
In fact, sessions exist on both the client and server.
If you have already written a Session in development, open the Firefox browser, and clear the cookie, you will find a cookie of session_id (the java developer will see JSESSIONID). After deletion, the Session will become invalid.
If you open the IE browser, the Session still exists after the cookie is cleared. I don't know how to deal with IE. Maybe it only clears the Session from the disk.
Session implementation principle
1. When a Session is created, the server generates a unique sessionid and uses it to generate a cookie that will expire when the browser is closed.
2. Then, add a data item associated with this sessionid to the hash table.
For example, Session ["UserName"] = 23;
If sessionid is 123, a row is appended to the hash table.
Sessionid username
123 23
3. When the browser submits the information to the server, it uses sessionid = 123 to retrieve the Session information of the user from the scattered list.