Session

Session

1. Represents a session between the client and the server;

2. The middle end session of the web refers to the period of time from entering the website to closing the browser when users browse a website, that is, the time spent by users browsing the website

In short: session is actually a specific concept of time.

3. The sessions of different users are saved in the server memory

Session object

1. Session object is the built-in object of JSP

2. The session object is automatically created when the first JSP page is loaded to complete session management.

3. A session starts when the client opens the browser and connects to the server, and ends when the client closes the browser and leaves the server;

4. When a client accesses a server, it may switch between several pages of the server. The server should know that this is a client in some way, so it needs a session object;

5. The session object is an instance of the httpsession class;

6. The default session timeout of Tomcat is 30 minutes;

7. Set session Setmaxinactivitintervel (time)// Unit / second

8. On the web Set in XML, unit / minute

        10

Session lifecycle

1. Create:

When the client accesses a JSP or servlet for the first time, the server will create a sessionid for the current session. Each time the client sends a request to the server, it will carry this sessionid, and the server will verify this sessionid;

2. Activities:

New pages opened through hyperlinks in a session belong to the same session;

As long as the current session is not completely closed, reopening a new browser window to access the same project resources belongs to the same session;

Unless all the pages of this session are closed, re accessing a JSP page or servlet will create a new session;

Note: the original session still exists, but the old sessionid still exists on the server, but no client will carry it to the server for verification, and the old session will be automatically destroyed when it times out;

3. Destruction

* call session Destroy with the invalidate () method

* session expired

* server restart

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>