Javaweb Foundation-Session Management sessions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.