Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 1.02 KB

README.md

File metadata and controls

30 lines (19 loc) · 1.02 KB

#connect-mysql

This is a very, very simple MySQL backed session store for connect.

It uses an already established node-mysql client for the connection, and creates a 'sessions' table if it doesn't exist.

To use:

var express = require('express'),
    mysql = require('mysql').createClient({ user: 'dbuser', password: 'dbpassword', database: 'db' }),
    MySQLStore = require('connect-mysql')(express);

var app = express.createServer();
app.use(express.cookieParser());
app.use(express.session({ secret: 'supersecretkeygoeshere', store: new MySQLStore({ client: mysql })));

For MySQL pool support:

...
    mysql = require('mysql').createPool({ user: 'dbuser', password: 'dbpassword', database: 'db' }),
...

Options:

  • client - the mysql client instance or pool
  • cleanup - a boolean specifying whether to enable the cleanup events. note that if this is disabled, cleanup will not take place at all and should be done externally.

License: MIT