First, what is the session
The session is similar to the client's account on the server side. Use Map to store
A session locks a user (typically a client, which is a single Session object by a browser), and can be shared even if the browser accesses other program resources.
(How do I determine the same user?) When the session is created, the SessionID is passed to the client in the form of a cookie, and the client accesses the SessionID to pass the verification
Jsessionid
)
Ii. the difference between a session and a cookie
The cookie saves the user's data to the browser side, and thesession saves the user's data to the server.
Cookies are saved in a browser that is unsafe (cookie spoofing), but can relieve server stress
Session save is more secure on the server side, but increases server pressure
Browsers generally allow only 300 cookies, with a maximum of 20 cookies per site and a limit of 4KB per cookie size
Usually put important information such as login password to the session other relatively unimportant information put cookies
Fill in more:
Cookies are a kind of data storage function implemented by the browser.
The session literally means the conversation, the session will know who you are talking to, sessions are similar to the truth, the server to know the current request to their own who
Third, the operation of the session
The Request.getsession () method gets the session to actually create the session at the first call of the method (the IsNew () method can be used to determine if it is new)
The default session will survive for 30 minutes, and you can configure the expiration time in Web. xml
<session-config> <session-timeout>15</session-timeout> </session-config>
The program uses Session.invalidate () to set the expiration manually
The solution when the cookie is disabled (the cookie is disabled and the jsessionid is nowhere to be stored):
Resolution: URL Rewriting
Response. Encoderedirecturl (String URL)
Used to override the URL address after the Sendredirect method.
Response. Encodeurl (String URL)
Used to override the URL address of the form action and hyperlink
Both of these are smart ways to rewrite at the right time.
Javaweb Foundation-Session Management sessions