First, in the Conf/context.xml file, add the following configuration to the root node:
<manager classname= "Org.apache.catalina.session.PersistentManager" maxactivesessions= "-1" minidleswap= "-1" maxidleswap= "-1" maxidlebackup= "-1" > <store classname= "Org.apache.catalina.session.JDBCStore" drivername= "Com.mysql.jdbc.Driver" connectionurl= "JDBC: Mysql://2.2.2.76:3306/test_session?user=user&password=password " sessiontable= "Sessions" sessionidcol= "session_id" sessiondatacol= "Session_data" sessionvalidcol= "valid_ Session " sessionmaxinactivecol=" Max_inactive " Sessionlastaccessedcol= "Last_access" &Nbsp;sessionappcol= "App_name" checkinterval= " /> </Manager>"
Second, copy the Mysql-connector-java-5.1.34-bin.jar to the Tomcat Lib directory, or you will not find the driver!
In the third step, execute the following script in the database test_session to create a table to store the session data, complete
CREATE TABLE Sessions (session_id VARCHAR) not null PRIMARY KEY, valid_session CHAR (1) is not NULL, Max_inac tive INT NOT NULL, last_access BIGINT NOT NULL, app_name VARCHAR (255), Session_data Mediumblob, KEY Kapp_name (app_name));
If you need to adjust the relevant parameters, you can refer to the Tomcat documentation: http://tomcat.apache.org/tomcat-6.0-doc/config/manager.html
Configure Tomcat to persist the session to MySQL