0.1.4 • Published 3 years ago
express-session-mariadb-store v0.1.4
A express session store with the mariadb connector
Install
npm install express-session-mariadb-store
yarn add express-session-mariadb-store
make sure you have a database with a table create like the following example:
CREATE TABLE session(
sid VARCHAR(100) PRIMARY KEY NOT NULL,
session VARCHAR(2048) DEFAULT '{}',
lastSeen DATETIME DEFAULT NOW()
);
Use
commonJS (New connection pool)
const session = require('express-session')
const MariaDBStore = require('express-session-mariadb-store')
app.use(session({
store: new MariaDBStore({
user: 'user',
password: 'password'
})
}))
commonJS (Reuse connection pool)
const session = require('express-session')
const MariaDBStore = require('express-session-mariadb-store')
app.use(session({
store: new MariaDBStore({
pool: existingConnectionPool
})
}))
Config
All config options for the MariaDBStore:
key | default |
---|---|
sessionTable | 'session' |
host | 'localhost' |
user | undefined |
password | undefined |
database | 'sessiondb' |
connectionLimit | 5 |
pool | undefined |