Skip to content

Implementation of an express-session store using SQL Server.

Notifications You must be signed in to change notification settings

roundsToThree/mssql-session-store

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mssql-session-store

Implementation of an express-session store using SQL Server. Uses mssql to connect to the database.

Installation

$ npm install mssql-session-store

Important:

The store is expecting this table to exist in your database.

create table Session
(
  sessionId nvarchar(450) not null primary key,
  sessionData nvarchar(max) null,
  lastTouchedUtc datetime not null  
)

Example

var session = require('express-session')
var MssqlStore = require('mssql-session-store')(session);

app.use(session({
  secret: 'keyboard cat',
  resave: false,
  saveUninitialized: false,
  store: new MssqlStore(options) // see options below
}));

Options

var options = {
	connection: existingConnection,
	ttl: 3600,
	reapInterval: 3600,
	reapCallback: function() { console.log('expired sessions were removed'); }
};

connection

Default value: undefined

Optional instance of a Connection from mssql. If undefined then the global connection will be used.

ttl

Default value: 3600

Optional time to live in seconds. Sessions that have not been "touched" in this amount of time will be destroyed. If reapInterval is set to -1 then this setting has no effect.

reapInterval

Default value: 3600

Optional interval to destroy expired sessions in seconds or -1 to never remove expired sessions. Fires once on construction of the MssqlStore object (unless reapInterval is set to -1).

reapCallback

Default value: undefined

Optional callback that is fired after each reaping.

License

http://jwathen.mit-license.org

About

Implementation of an express-session store using SQL Server.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%