What is 1.session?
1.1 Session is a conversational technology PS: There is also a cookie
The role of 2.session
2.1 Server-side session-wide data sharing
Life cycle of 3.session
3.1 Created when Request.getsession () is created (because the session is related to cookies)
3.2 Destruction (three methods of destruction)
3.2.1 Default 30-minute expiration
3.2.2 Write a method to destroy invalidate ()
3.2.3 Server shutdown is not normal
Passivation and reduction of 4.session
4.1 passivation
When the server shuts down normally, the session in memory is saved in a file (Apache server is in work directory)
4.2 Restore
When the server starts again when it shuts down normally, the server-side session that is not expired is restored to memory
Principle of 5.session (Jsessionid)
When a client has a session with the server, the server will determine if the request's cookie contains a jsessionid cookie, create one if not, and use it to differentiate the user and manipulate the session
6. Question: How the server distinguishes the current access from which user a: Use the Jesessionid from the client
7. Problem extension (think): What happens when a client disables cookies? A: When the client disables cookies, then the server side of the session is not available, because the session is based on cookie technology, so that some functions based on the session can not be used, such as the use of the session function to achieve the shopping function, Then we have to identify the user in other ways, which is URL redirection. URL redirection is a parameter that writes SessionID in the URL as a URL, which can also be used to differentiate users.
8. Problem: Use session to achieve shopping, payment function, and when the user closes the browser can also be settled
8.1 Knowledge Points: Session application, session is based on the cookie, and the ordinary cookie is session level when the browser is closed, the cookie is destroyed, and now the need is to open the browser when it is closed again when it can be settled, That is, the Jsessionid value is one before and when it is turned off, which means that the cookie with the name Jsessionid is saved in the browser temp file.
9.session Example: Shopping payment
Add: How to set timeout time for session Java and. NET are set in the Web configuration file
Wisdom Podcast Javaweb Day05-session