In general, if a user opens a browser, the server assigns a SessionID, and the Session.getid () function returns the ID of the session;
However, if once the server is shut down, the server restarts and the page is refreshed, the server will reassign a new SessionID;
If we want to retain the original ID, we can save the SessionID by serialization.
In Conf/server.xml, add in the context, Web project
<context path= "/test" docbase= "F:\JAVA WEB practice\tomcatproject" reloadable= "true" >
<manager Classname= "Org.apache.catalina.session.PersistentManager" >
debug=0 saveonrestart= "true"
maxactivesession= "-1" minidleswap= "-1"
maxidleswap= "-1" maxidlebackup= "-1"
<store classname= "Org.apache.catalina.session.FileStore" directory= "F:\JAVA WEB practice\tomcatproject\temp"/>
</manager >
</Context>
Indicates that the serial number exists under F:\JAVA WEB practice\tomcatproject\temp;
The effect of the implementation is this:
1. Open a Web page, the purpose of which is to output session ID;
2. To turn off Tomcat, a temporary file appears under the Temp folder;
3. Reboot Tomcat;
4. Refresh the page, the session ID unchanged;