JSPM

  • Created
  • Published
  • Downloads 18679
  • Score
    100M100P100Q137255F
  • License MIT

cookies module for egg

Package Exports

  • egg-cookies
  • egg-cookies/lib/cookies.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (egg-cookies) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

egg-cookies@2

NPM version build status Test coverage 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.

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

Contributors


fengmk2


dead-horse


semantic-release-bot


atian25


whxaxes


xyeric


jedmeng


Junyan


beliefgp


snapre


popomore


tang-xy


ziyunfei


brizer


xuezier


onlylovermb

This project follows the git-contributor spec, auto updated at Mon Feb 19 2024 17:41:40 GMT+0800.