express-sql-session
A SQL session store for express.js
Installation
Add to your application via npm
:
npm install express-sql-session --save
This will install express-sql-session
and add it to your application's package.json
file.
How to Use
To use express-sql-session
, simply use it with your express session middleware, like this:
var express = ;var app = moduleexports = ; var session = ;var SessionStore = session; var options = client: 'mysql' connection: host: 'localhost' port: 3306 user: 'session_test' password: 'password' database: 'session_test' table: 'sessions' expires: 365 * 24 * 60 * 60 * 1000 // 1 year in ms; var sessionStore = options app
Debugging
express-sql-session
uses the debug module to output debug messages to the console. To output all debug messages, run your node app with the DEBUG
environment variable:
DEBUG=express-mysql-session* node your-app.js
This will output log messages as well as error messages from express-sql-session
.