Tomcat implements persistent session ID Storage

Source: Internet
Author: User
Tags session id

Generally, if a user opens a browser, the server will allocate a sessionid, and the session ID can be returned through the session. GETID () function;

However, if the server is shut down, restart the server, and refresh the page, the server will re-allocate a new sessionid;

If you want to retain the original ID, you can save the sessionid in serialization mode.

In CONF/server. XML, add

<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 is stored in F: \ Java Web practice \ atatproject \ Temp;

The effect is as follows:

1. Open a webpage to output the session ID;

2. Close tomcat, a temporary file will appear in the temp folder;

3. Restart tomcat;

4. Refresh the page, and the session ID remains unchanged;

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.