You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

koa-generic-session-file

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-generic-session-file

Static file store for koa-generic-session

0.2.1
latest
npm
Version published
Maintainers
1
Created
Source

Koa Generic Session File store

This plugin for koa-generic-session is for when you just want basic file-based session stores. It's useful when you want persistent sessions for a small number of users without having to spin up an instance of Redis or Mongo.

Installation

Install via npm:

npm install koa-generic-session-file

Usage

Just plug it into koa-generic-session as you would with the other generic stores. For example:

var Koa = require("koa");
var session = require("koa-generic-session");
var FileStore = require("koa-generic-session-file");

var app = new Koa();
app.keys = ["keys", "keykeys"];

app.use(session({
  store: new FileStore()
}));

By default, the middleware will store session files in a directory called "sessions" relative to your application's cwd. You can customise this path in the options.

Options

You can customise the behaviour of the store in a few small ways by passing options in when instantiating FileStore:

  • sessionDirectory: use this if you want to store your session files in a custom location. It should be a path relative to your process.cwd() path, or an absolute path.
app.use(session({
  store: new FileStore({
    sessionDirectory: "/absolute/path/to/my/sessions"
  })
}));

FAQs

Package last updated on 01 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts