# egg-cookies [![NPM version][npm-image]][npm-url] [![build status][ci-image]][ci-url] [![Test coverage][codecov-image]][codecov-url] [![npm download][download-image]][download-url] [npm-image]: https://img.shields.io/npm/v/egg-cookies.svg?style=flat-square [npm-url]: https://npmjs.org/package/egg-cookies [ci-image]: https://github.com/eggjs/egg-cookies/actions/workflows/nodejs.yml/badge.svg [ci-url]: https://github.com/eggjs/egg-cookies/actions/workflows/nodejs.yml [codecov-image]: https://codecov.io/gh/eggjs/egg-cookies/branch/master/graph/badge.svg [codecov-url]: https://codecov.io/gh/eggjs/egg-cookies [download-image]: https://img.shields.io/npm/dm/egg-cookies.svg?style=flat-square [download-url]: https://npmjs.org/package/egg-cookies Extends [pillarjs/cookies](https://github.com/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. ```js 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](http://browsercookielimits.squawky.net/), 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. ```js const Cookies = require('egg-cookies'); const cookies = new Cookies(ctx, keys); cookies.on('cookieLimitExceed', { name, value } => { // log }); cookies.set('foo', longText); ``` ## License [MIT](LICENSE.txt) ## Contributors |[
dead-horse](https://github.com/dead-horse)
|[
fengmk2](https://github.com/fengmk2)
|[
atian25](https://github.com/atian25)
|[
whxaxes](https://github.com/whxaxes)
|[
xyeric](https://github.com/xyeric)
|[
jedmeng](https://github.com/jedmeng)
| | :---: | :---: | :---: | :---: | :---: | :---: | |[
Junyan](https://github.com/Junyan)
|[
beliefgp](https://github.com/beliefgp)
|[
snapre](https://github.com/snapre)
|[
popomore](https://github.com/popomore)
|[
ziyunfei](https://github.com/ziyunfei)
|[
brizer](https://github.com/brizer)
| [
xuezier](https://github.com/xuezier)
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Jun 20 2022 12:14:02 GMT+0800`.