arsenic-mysql-session-store

1.0.0 • Public • Published

node-mysql-session-store

Summary

Provides a MySQL Session store for Node.js and Express.

node-logger

Installation

Setup a session table in your database;

CREATE TABLE `sessions` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `expires` int(11) DEFAULT NULL,
  `data` text,
  `sid` varchar(120) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=399 DEFAULT CHARSET=utf8;

Then just copy the SqlSessionStore.js file into your project, and then use

var SqlSessionStore = require('./node/models/SqlSessionStore.js')(express);

Usage

Usage is quite simple, the following shows a full example;

var express = require('express');
var SqlSessionStore = require('./node/models/SqlSessionStore.js')(express);
 
var app = express();
 
//noinspection JSValidateTypes
app.configure(function()
{
    app.set('port', process.env.PORT || 3030);
    app.use(express.favicon(__dirname + '/public/favicon.ico'));
    app.use(express.cookieParser());
 
    app.use(express.session({
        cookie: {
            path: '/admin/',
            httpOnly: false,
            maxAge: null
        },
        secret: "yourpasword",
        store: new SqlSessionStore()
    }));
 
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(path.join(__dirname, 'public')));
});

Requirements

Requires AdAstra's node-logger (https://github.com/adastra/node-logger) for logging calls, though this is easily remove if you wish to use a different solution.

Also requires AdAstra's MySQL database manager class (https://github.com/adastra/node-mysql-database-manager)

License

(The MIT License)

Copyright (C) 2012 by Ad Astra Systems, LLC;

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Readme

Keywords

none

Package Sidebar

Install

npm i arsenic-mysql-session-store

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • thepipster