Git Product home page Git Product logo

connect-mysql-session's Introduction

connect-mysql-session

A MySQL session store for the connectjs session middleware for node.js.

Currently, this code appears to function correctly but it has not been optimized for performance. The store is implemented using sequelize ORM, simply dumping the JSON-serialized session into a MySQL TEXT column.

Installation

Using npm:

npm install -g connect-mysql-session

By cloning the repo:

git clone git://github.com/CarnegieLearning/connect-mysql-session.git
cd connect-mysql-session
npm link

(Note: in both cases you may need to use sudo when performing the npm step.)

Usage

The following example uses expressjs, but this should work fine using connectjs without the expressjs web app layer.

var express = require('express'),
    MySQLSessionStore = require('connect-mysql-session')(express);

var app = express.createServer();
app.use(express.cookieParser());
app.use(express.session({
    store: new MySQLSessionStore("dbname", "user", "password", {
        // options...
    }),
    secret: "keyboard cat"
}));
...

Options

forceSync

Default: false. If set to true, the Sessions table will be dropped before being reinitialized, effectively clearing all session data.

checkExpirationInterval

Default: 1000*60*10 (10 minutes). How frequently the session store checks for and clears expired sessions.

defaultExpiration

Default: 1000*60*60*24 (1 day). How long session data is stored for "user session" cookies -- i.e. sessions that only last as long as the user keeps their browser open, which are created by doing req.session.maxAge = null.

Changes

0.1.1 and 0.1.2 (2011-08-03)

  • Lazy initialization to ensure model is ready before accessing.
  • Index the sid column.

0.1.0 (2011-07-19)

  • Initial version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.