# cookie-storage

> A Web Storage interface for Cookie

Latest version **6.1.0** (published 2020-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install cookie-storage
pnpm add cookie-storage
yarn add cookie-storage
bun add cookie-storage
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.1.0 |
| Published | 2020-08-07 |
| First published | 2015-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 42 |
| Author | bouzuya |
| Maintainers | bouzuya |
| Keywords | browser, cookie, storage |

## Links

- npm: https://www.npmjs.com/package/cookie-storage
- Repository: https://github.com/bouzuya/cookie-storage
- Issues: https://github.com/bouzuya/cookie-storage/issues
- npm.io page: https://npm.io/package/cookie-storage

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 6.1.0 (latest) — 2020-08-07
- 6.0.0 — 2020-01-25
- 5.0.3 — 2019-08-03
- 5.0.2 — 2019-07-11
- 5.0.1 — 2019-05-05
- 5.0.0 — 2019-05-05
- 3.2.0 — 2018-08-16
- 3.1.0 — 2017-10-20
- 3.0.0 — 2017-05-16
- 2.0.2 — 2016-09-05
- 2.0.1 — 2016-09-04
- 1.0.4 — 2015-08-05
- 1.0.3 — 2015-06-12
- 1.0.2 — 2015-06-12
- 1.0.0 — 2015-03-22

## README

![cookie-storage](https://cloud.githubusercontent.com/assets/1221346/18493417/7243e872-7a4b-11e6-933a-1c3fe3cfaa71.png)

cookie-storage: A Web Storage interface for Cookie.

[Storage interface spec](https://html.spec.whatwg.org/multipage/webstorage.html#the-storage-interface).

## Installation

```
$ npm install cookie-storage
```

## Usage

```javascript
import { CookieStorage } from 'cookie-storage';

const cookieStorage = new CookieStorage();

cookieStorage.length === 0;
cookieStorage.getItem('key') === null;

cookieStorage.setItem('key', 'value');
cookieStorage.length === 1;
cookieStorage.key(0) === 'key';

cookieStorage.getItem('key') === 'value';
cookieStorage.removeItem('key');
cookieStorage.length === 0;

cookieStorage.setItem('k1', 'v1');
cookieStorage.setItem('k2', 'v2');
cookieStorage.length === 2;

cookieStorage.clear();
cookieStorage.length === 0;

// Cookie options
cookieStorage.setItem('key', 'value', {
  path: '/',
  domain: 'example.com',
  expires: new Date(),
  secure: true,
  sameSite: 'Strict' // Can be 'Strict' or 'Lax'.
});

// Use default cookie options
const storage = new CookieStorage({
  path: '/',
  domain: 'example.com',
  expires: new Date(),
  secure: true,
  sameSite: 'Strict' // Can be 'Strict' or 'Lax'.
});
storage.setItem('key', 'value'); // ;path=/;domain=example.com;...
```

## Development

```
$ npm install
$ npm run watch
```

## Badges

[![NPM][npm-badge]][npm]
[![Travis CI][travis-ci-badge]][travis-ci]

[npm]: https://www.npmjs.com/package/cookie-storage
[npm-badge]: https://img.shields.io/npm/v/cookie-storage.svg
[travis-ci]: https://travis-ci.org/bouzuya/cookie-storage
[travis-ci-badge]: https://img.shields.io/travis/bouzuya/cookie-storage.svg

## License

[MIT](LICENSE)

## Related Project

- [bouzuya/simple-memory-storage][]

[bouzuya/simple-memory-storage]: https://github.com/bouzuya/simple-memory-storage

## Contributors

- [astegmaier (Andrew Stegmaier)](https://github.com/astegmaier)
- [nihakue (Gabriel West)](https://github.com/nihakue)

## Author

[bouzuya][user] &lt;[m@bouzuya.net][email]&gt; ([http://bouzuya.net][url])

[user]: https://github.com/bouzuya
[email]: mailto:m@bouzuya.net
[url]: http://bouzuya.net

---
_Source: https://npm.io/package/cookie-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
