Why is jsessionid available ?, Jsessionid

Source: Internet
Author: User

Why is jsessionid available ?, Jsessionid

1. Is a jsessionid generated when a page is opened? 2. When will the jsessionid change without closing the browser? After I log on, log on and exit. What changes will jsessionid be made? 3. What is the relationship between session and jsessionid? Thank you!

The so-called session can be understood as follows: When a session is held with the server, for example, after a successful login, the server opens a memory interval for the user to store some content of the user's session, for example, user name. You need something to indicate that the memory range is yours rather than others'. This is session id (jsessionid is only the name of session id in tomcat. In other containers, not necessarily jsessionid .), This memory interval can be understood as session. Then, the server will send the session id back to your browser and put it into your browser's cookies (this cookie is a memory cookie, which is different from the general one, it will disappear with the close of the browser ). After that, only your browser is not closed. Every time you send a request to the server, the server will take out the session id from the cookies you sent, then, based on the session id, go to the corresponding memory to retrieve the data you previously stored. However, if you log out, the server will clear your memory region, so if you log on again, a new session will be generated.

What is jsession: jsessionid is the identifier of the session. This is like everyone has an ID card.

 

Jsessionid is interpreted as follows:

This is an insurance measure because Session requires Cookie support by default, but some client browsers disable Cookies [and jsessionid is stored in cookies. If Cookie is disabled, that is to say, the server cannot get the jsessionid, so that the corresponding session cannot be obtained based on the jsessionid. If the session cannot be obtained, the data stored in the session cannot be obtained.] In this case, you need to specify the session ID on the server in the URL, which is similar to the format "jsessionid = 5F4771183629C9834F8382E23BE13C4C. You can use a method (forget the name of the method) to process the URL string to get this thing. This method will determine whether your browser has enabled the Cookie, if he thinks he should add him, he will add him.

1. Is a jsessionid generated when a page is opened? A: Obviously not. The session has a certain scope and has a time limit.

2. When will the jsessionid change without closing the browser? After I log on, log on and exit. What changes will jsessionid be made? A: The jsessionid is generated by the server because the cookie is sent from the server to the client. No matter whether jsessionid can be modified, it should not be modified. If you modify it, it will lose the meaning of the jessionid. If you modify it, how can you find the corresponding session on the server? If no data is found, isn't the data you stored in that session lost? Log in and exit. I think a jsessionid will be generated again. If the application is exited, data in the application scope will be lost. What's more, this session is smaller than the application scope? Since all sessions have disappeared, what is the use of this jsessionid?

3. jsessionid is the ID of the session. This is like everyone has an ID card.

Cookie and session mechanisms differ from each other. Specifically, the cookie mechanism adopts the client-side persistence scheme, while the session mechanism adopts the server-side persistence scheme. At the same time, we can also see that because the server-side persistence scheme also needs to save an identifier on the client, the session mechanism may need to use the cookie Mechanism to save the identifier, but in fact it has other options.

Cookie Mechanism. The orthodox cookie distribution is implemented by extending the HTTP protocol. The server prompts the browser to generate the corresponding cookie by adding a special line in the HTTP response header. However, pure client scripts such as JavaScript or VBScript can also generate cookies. Cookies are automatically sent to the server in the background by the browser according to certain principles. The browser checks all stored cookies. If the declared range of a cookie is greater than or equal to the location where the requested resource is located, the cookie is attached to the HTTP request header of the requested resource and sent to the server. Cookie content mainly includes: name, value, expiration time, path and domain. The path and the domain form the scope of the cookie. If no expiration time is set, it indicates that the cookie's life cycle is the browser session period. When the browser window is closed, the cookie disappears. This cookie is called a session cookie. Session cookies are generally stored in the memory instead of on the hard disk. Of course, this behavior is not standardized. If the expiration time is set, the browser will save the cookie to the hard disk, close it, and open the browser again. These cookies are still valid until the preset expiration time is exceeded. Cookies stored on hard disks can be shared among different browser processes, such as two IE Windows. For Cookies stored in the memory, different browsers have different session mechanisms. The session mechanism is a server-side mechanism. The server uses a structure similar to a hash (or a hash) to save information. When the program needs to create a session for a client request, the server first checks whether the client request contains a session id (called session id ), if it already exists, it indicates that a session has been created for this client. Then, the server retrieves and uses this session according to the session id (a new session will be created if it cannot be retrieved ), if the client request does not contain the session id, the client creates a session and generates a session id associated with the session. The session id value should be unique, the session id is returned to the client for saving in this response. The cookie can be used to save the session id. In this way, the browser can automatically display the id to the server according to the Rules during the interaction. Generally, the cookie name is similar to SEEESIONID. However, if a cookie can be artificially disabled, there must be other mechanisms so that the session id can still be passed back to the server when the cookie is disabled. A frequently used technology called URL rewriting is to directly append the session id to the end of the URL path. Another technique is form hidden fields. The server automatically modifies the form and adds a hidden field so that the session id can be passed back to the server when the form is submitted.

Obtain 【]Springmvc mybatis (oracle and mysql) HTML5 new high-performance background framework bootstrap

Related Article

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.