Registry / database / connect-mysql-session

connect-mysql-session

JSON →
library0.1.3jsnpmunverified

A MySQL session store for connect, the Node.js middleware framework. Version 0.1.3 is the latest stable release. This package provides a straightforward way to persist session data in MySQL, leveraging the node-mysql driver. It is designed for older versions of Node.js (pre-0.6) and connect. Compared to more modern session stores like connect-mysql, this package is simple but lacks active maintenance and is incompatible with newer Node.js versions.

npm install connect-mysql-session
INSTALL
IMPORT
SIG · CONNECT-MYSQL-SESS
C
connect-mysql-session
databasejavascriptv0.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
var MySQLStore = require('connect-mysql-session');
import MySQLStore from 'connect-mysql-session';
Package uses CommonJS, ESM not supported.
connect
var connect = require('connect');
import connect from 'connect';
connect is a CommonJS module.
node-mysql
var mysql = require('node-mysql');
import mysql from 'node-mysql';
node-mysql is CommonJS.

Sets up a connect app with MySQL-backed session store, creating database and table if not exist.

var connect = require('connect'); var MySQLStore = require('connect-mysql-session'); var mysql = require('node-mysql'); var db = mysql.createClient({ host: process.env.MYSQL_HOST || 'localhost', port: process.env.MYSQL_PORT || 3306, user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD || '' }); db.query('CREATE DATABASE IF NOT EXISTS session_test'); db.query('USE session_test'); db.query('CREATE TABLE IF NOT EXISTS sessions (session_id VARCHAR(255) PRIMARY KEY, expires VARCHAR(255), data TEXT)'); var sessionStore = new MySQLStore(db, { table: 'sessions' }); var app = connect(); app.use(connect.cookieParser()); app.use(connect.session({ store: sessionStore, secret: 'keyboard cat' })); app.use(function(req, res){ req.session.views = (req.session.views || 0) + 1; res.end('views: ' + req.session.views); }); app.listen(3000);
Debug
Known issues
deprecatedPackage is no longer maintained and uses outdated dependencies.
fix
Migrate to a maintained session store like connect-mysql or express-mysql-session.
affects: >=0.0.0
breakingRequires Node.js ~0.4, incompatible with modern Node.js versions.
fix
Use an alternative session store with current Node.js support.
affects: >=0.1.0
gotchaThe session table must be created manually; automatic table creation is not supported.
fix
Execute CREATE TABLE statement before using the store.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'connect-mysql-session'
Package not installed or module resolution fails.
fix
Run 'npm install connect-mysql-session' in your project directory.
TypeError: Object #<Object> has no method 'query'
The MySQL client instance is not initialized properly.
fix
Ensure you call mysql.createClient() and pass the client, not the mysql module.
Error: connect.session() requires a session store
Session store not passed to connect.session() middleware.
fix
Provide the store option: connect.session({ store: sessionStore, secret: '...' })
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
connectrequiredPeer dependency: session store is intended for use with the connect framework.
node-mysqlrequiredRequired to interact with MySQL database.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
connect-mysql-session — npm install connect-mysql-session · libregistry