Is an implementation of a tomcat 4.X Store that use a table to store sessions. When to store sessions is configured in the Manager, currently
the only Manager supported is the PersistentManager. Please consult the Manager manual for configuring the PersistentManager.
All the parameters, drivers, tables, and columns are user configurable.
I made the database named "tomcat"
1. The session table.
This table holds the sessions currently stored due to backup/swapout/maxidle or other criteria met.
create database tomcat; create table tomcat$sessions ( id varchar(100) not null primary key, valid char(1) not null, maxinactive int not null, lastaccess bigint, data mediumblob );
Here is sample output from the tables:
mysql> create database tomcat; Query OK, 1 row affected (0.02 sec) mysql> use tomcat; Database changed mysql> create table tomcat$sessions -> ( -> id varchar(100) not null primary key, -> valid char(1) not null, -> maxinactive int not null, -> lastaccess bigint, -> data mediumblob); Query OK, 0 rows affected (0.01 sec)
3. Configure Tomcat
Add the information to the server.xml file. Make sure that you configure the Store inside a Manger. PersistentManager is the only one supported as of writing. For this example I used this entry inside:
<Manager className="org.apache.catalina.session.PersistentManager" debug="0" saveOnRestart="true" maxActiveSessions="-1" minIdleSwap="-1" maxIdleSwap="-1" maxIdleBackup="-1">
The meaning of the attributes is as follow:
Meaning className The class to use as a Store, If you want to use a different Store than JDBCStore you're reading the wrong file driverName The name of the driver needed to connect to the database connectionURL The connection URL used to connect to the database sessionTable The table in which we store our sessions sessionIdCol The column in the session table that contains the session ID sessionDataCol The column in the session table that contains the session data sessionValidCol The column in the session table that holds if the session is valid or not. sessionMaxInactiveCol The column in the session table that contains the sessions Max Inactive property sessionLastAccessedCol The column in the session table that contains the last accesed time checkInterval The time in seconds for the processExpires thread to sleep, a lower value causes more accurate expiring and removing old sessions from the RDBMS but could cause a heavily loaded site to go on it's knees if set to low. debug The debug level for this Store, 0 means don't log any debug information and that's probably what you would want for a production enviroment.