Session expiration means that there is no action for a long time during the connection between the user session and the server, or the connection exceeds the validity period; when the session expires, the session data of the user session will be cleared or recycled. The session expiration time is generally set to 30 minutes.
The operating environment of this tutorial: Windows 7 system, Dell G3 computer.
What does session expiration mean?
Session invalidation is also commonly referred to as session expiration. That is to say, when no connection operation is triggered on the server, it is emptied or recycled within the specified time so that the content disappears. The general configuration is It's 30 minutes.
What is Session?
In computers, especially in network applications, it is called "session control". The Session object stores the properties and configuration information required for a specific user session. In this way, when the user jumps between Web pages in the application, the variables stored in the Session object will not be lost, but will persist throughout the user session. When a user requests a Web page from an application, the Web server automatically creates a Session object if the user does not already have a session.
When the session expires or is abandoned, the server will terminate the session. One of the most common uses of Session objects is to store user preferences. For example, if the user indicates that he or she does not like to view graphics, this information can be stored in the Session object. For more information about using the Session object, see "Managing Sessions" in the "ASP Applications" section. Note Session state is only preserved in browsers that support cookies.
session analysis knowledge points:
1.session is actually a Map, key = value pair, and the settings in the session are obtained through session.getAttribute("name"); Parameters
2. When does the expiration time of session start to be calculated? Does it start counting as soon as you log in or does it start counting when you stop being active?
Answer: It is calculated from the time when the session is inactive. If the session is always active, the session will never expire.
The timing starts when the Session is not accessed; once the Session is accessed, the timing is cleared to 0;
3. Set the session expiration time
a) in web.xml
<session-config> <session-timeout>30</session-timeout> </session-config>//单位为分钟
b) Manually set it in the program
session.setMaxInactiveInterval(30 * 60);//设置单位为秒,设置为-1永不过期
c) Tomcat can also modify the session expiration time. When defining context in server.xml, use the following definition:
<Context path="/livsorder" docBase="/home/httpd/html/livsorder" defaultSessionTimeOut="3600" isWARExpanded="true" isWARValidated="false" isInvokerEnabled="true" isWorkDirPersistent="false"/>
The above is the detailed content of What does session expiration mean?. For more information, please follow other related articles on the PHP Chinese website!