Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Create a case analysis of Session

Shulou Source: shulou.com Published: 2022-06-01 11:54:01 10月04日 Update

This article shows you the example analysis of creating Session, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Q: the browser visits a site, generates a session, and then does the following:

1. Open a new tab card in the same browser and visit the same site. At this time, several session

2. When you drag the newly opened tab card out and become two browsers, create several session

3. Change your browser and visit the same site. At this time, several session

4. Is HttpSession, HttpServletRequest.getSession (), HttpServletRequest.getSession (true) and HttpServletRequest.getSession (false) the same session?

Let's take a look at the first session1 generated.

Visit the local tomcat and store the first sessionId as session, and you can see that the four sessionId are the same.

Newly open tab and compare two sessionId2

It is found that the sessionId of two tab cards is also the same.

After dragging it out,

three

Found that the two sessionId are still the same.

Change the FF and open it again.

It's finally different from what it was before.

1. For the same browser, without clearing the cookie, caching or closing the browser, if the expiration time is not reached, the session is the same.

two。 After being dragged out, the session is still the same

3. Change the browser, change the session

4.HttpSession, HttpServletRequest.getSession (), HttpServletRequest.getSession (true), HttpServletRequest.getSession (false) get the same session

Extraneous remarks

Session exists on the server. Because http is stateless, the server cannot tell which client sends the request, and ultimately relies on cookie. Each request sent carries a JSESSIONID, that is, the sessionId obtained by the server, which uniquely identifies a client request.

The above content is to create the case analysis of Session, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Browser browsing two same site service instance case analysis analysis content customer client skill knowledge concise concise premise that is article time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft macOS OPPO Reno Shulou Technology Shulou Information