<commit_before>generic-session
=========

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Coveralls][coveralls-image]][coveralls-url]
[![David deps][david-image]][david-url]
[![node version][node-image]][node-url]
[![npm download][download-image]][download-url]
[![Gittip][gittip-image]][gittip-url]

[npm-image]: https://img.shields.io/npm/v/koa-generic-session.svg?style=flat-square
[npm-url]: https://npmjs.org/package/koa-generic-session
[travis-image]: https://img.shields.io/travis/koajs/generic-session.svg?style=flat-square
[travis-url]: https://travis-ci.org/koajs/generic-session
[coveralls-image]: https://img.shields.io/coveralls/koajs/generic-session.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/koajs/generic-session?branch=master
[david-image]: https://img.shields.io/david/koajs/generic-session.svg?style=flat-square
[david-url]: https://david-dm.org/koajs/generic-session
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.11-red.svg?style=flat-square
[node-url]: http://nodejs.org/download/
[download-image]: https://img.shields.io/npm/dm/koa-generic-session.svg?style=flat-square
[download-url]: https://npmjs.org/package/koa-generic-session
[gittip-image]: https://img.shields.io/gittip/dead-horse.svg?style=flat-square
[gittip-url]: https://www.gittip.com/dead-horse/

Generic session middleware for koa, easy use with custom stores such as [redis](https://github.com/koajs/koa-redis) or [mongo](https://github.com/freakycue/koa-generic-session-mongo), supports defer session getter. different from [koa-session](https://github.com/koajs/session)(it is cookie session).

This middleware will only set a cookie when a session is manually set. Each time the session is modified (and only when the is session modified), it will reset the cookie and session.

You can use the rolling sessions that will reset the cookie and session for every request which touch the session.

## Usage

### Example

```js

var koa = require('koa');
var session = require('koa-generic-session');
var RedisStore = require('koa-redis');

var app = koa();
app.keys = ['keys', 'keykeys'];
app.use(session({
  store: new RedisStore()
}));

app.use(function *() {
  switch (this.path) {
  case '/get':
    get.call(this);
    break;
  case '/remove':
    remove.call(this);
    break;
  }
});
<commit_msg>readme: update<commit_after>generic-session
=========

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Coveralls][coveralls-image]][coveralls-url]
[![David deps][david-image]][david-url]
[![node version][node-image]][node-url]
[![npm download][download-image]][download-url]
[![Gittip][gittip-image]][gittip-url]

[npm-image]: https://img.shields.io/npm/v/koa-generic-session.svg?style=flat-square
[npm-url]: https://npmjs.org/package/koa-generic-session
[travis-image]: https://img.shields.io/travis/koajs/generic-session.svg?style=flat-square
[travis-url]: https://travis-ci.org/koajs/generic-session
[coveralls-image]: https://img.shields.io/coveralls/koajs/generic-session.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/koajs/generic-session?branch=master
[david-image]: https://img.shields.io/david/koajs/generic-session.svg?style=flat-square
[david-url]: https://david-dm.org/koajs/generic-session
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.11-red.svg?style=flat-square
[node-url]: http://nodejs.org/download/
[download-image]: https://img.shields.io/npm/dm/koa-generic-session.svg?style=flat-square
[download-url]: https://npmjs.org/package/koa-generic-session
[gittip-image]: https://img.shields.io/gittip/dead-horse.svg?style=flat-square
[gittip-url]: https://www.gittip.com/dead-horse/

Generic session middleware for koa, easy use with custom stores such as [redis](https://github.com/koajs/koa-redis) or [mongo](https://github.com/freakycue/koa-generic-session-mongo), supports defer session getter. different from [koa-session](https://github.com/koajs/session)(it is cookie session).

This middleware will only set a cookie when a session is manually set. Each time the session is modified (and only when the is session modified), it will reset the cookie and session.

You can use the rolling sessions that will reset the cookie and session for every request which touch the session.

## Usage

### Example

```js

var session = require('koa-generic-session');
var redisStore = require('koa-redis');
var koa = require('koa');

var app = koa();
app.keys = ['keys', 'keykeys'];
app.use(session({
  store: redisStore()
}));

app.use(function *() {
  switch (this.path) {
  case '/get':
    get.call(this);
    break;
  case '/remove':
    remove.call(this);
    break;
  }
});

{'fraction_non_alphanumeric': 0.1831105453002334, 'fraction_numerical': 0.001697432633142372, 'mean_word_length': 5.0669240669240665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 32, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6212825', 'n_tokens_mistral': 1711, 'n_tokens_neox': 1670, 'n_words': 304}