npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

session-store

v0.0.6

Published

A generic session store adapter

Downloads

9

Readme

session-store

session-store is a generic session interface for you to build a persistent (or not) store on top of. Bundled in this library you will find:

  • SessionManager: used to create Sessions
  • Session: represents a sessions state
  • Store: simple interface to build on
  • RedisStore: implements the Store interface using Redis
  • Express middleware

Using with Express

To use session-store with Express, you'll need the cookie-parser middleware.

var express = require('express');
var SS = require('session-store');
var cookieParser = require('cookie-parser');

var server = express();

var SessionManager = new SS.Manager(new SS.RedisStore());

server.use(cookieParser());

server.use(new SS.Middleware({
	sessionManager: SessionManager,
	cookieKey: 'my-cookie-key',
	salt: 'my-salt'
}));

server.get('/', function(req, res){
	req.session.set({ someAttribute: 'foobar' });
	res.send(200);
});

/*
	If run after hitting GET /, this will dump:
	
	{
		someAttribute: 'foobar'
	}
*/
server.get('/session', function(req, res){
	res.json(req.session);
});

Manager

var SS = require('session-store');

var manager = new SS.Manager();

var session = manager.createSession();

new SS.Manager(SS.Store store)

  • SS.Store an optional object that implements the SS.Store interface

RedisStore

var SS = require('session-store');

var redisStore = new SS.RedisStore({
	host: 'localhost',
	port: 6379
});

new SS.RedisStore(object options)

  • options is an object that can provide:
    • host where your redis server is located
    • port if you are running on the non-default port

Session

var SS = require('session-store');

var manager = new SS.Manager();

var session = manager.createSession();

session.set({ someKey: 'someValue' });
session.set('someKey', 'someValue');
session.set('someKey', 'someValue', true);

session.flush();


session.get();
/*
	{
		someKey: 'someValue'
	}
*/

session.destroy();


session.toJSON();
/*
	{
		someKey: 'someValue'
	}
*/

new SS.Session(SS.Store store, string id)

  • store is an instance object that implements SS.Store
  • id is a unique string to identify the session

Session.prototype.set(object data [, boolean forceFlush])

  • data is a object to store
  • forceFlush is a boolean to force a flush from memory to storage

Session.prototype.set(string key, string value [, boolean forceFlush])

Used to set a single key/value property

  • key the key to set
  • value the value to set the key to
  • forceFlush is a boolean to force a flush from memory to storage

Session.prototype.flush()

Flush the in-memory session to your session storage

Session.prototype.toJSON()

Returns a JSON representation of the data in the session store

Session.prototype.destroy()

Destroy the session and remove it from the store