egg-cookies
cookies module for egg
Last updated 5 years ago by dead_horse .
MIT · Repository · Bugs · Original npm
$ cnpm install egg-cookies 
SYNC missed versions from official npm registry.

egg-cookies

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Extends pillarjs/cookies to adapt koa and egg with some additional features.

Encrypt

egg-cookies provide an alternative encrypt mode like signed. An encrypt cookie's value will be encrypted base on keys. Anyone who don't have the keys are unable to know the original cookie's value.

const Cookies = require('egg-cookies');
const cookies = new Cookies(ctx, keys[, defaultCookieOptions]);

cookies.set('foo', 'bar', { encrypt: true });
cookies.get('foo', { encrypt: true });

Note: you should both indicating in get and set in pairs.

Cookie Length Check

Browsers all had some limitation in cookie's length, so if set a cookie with an extremely long value(> 4093), egg-cookies will emit an cookieLimitExceed event. You can listen to this event and record.

const Cookies = require('egg-cookies');
const cookies = new Cookies(ctx, keys);

cookies.on('cookieLimitExceed', { name, value } => {
  // log
});

cookies.set('foo', longText);

License

MIT

Current Tags

  • 2.6.1                                ...           latest (3 years ago)

4 Versions

  • 2.6.1                                ...           3 years ago
  • 2.4.2                                ...           5 years ago
  • 2.4.0                                ...           5 years ago
  • 2.3.3                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (12)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org