# @amphibian/write-cookie

> write browser cookie

Latest version **1.1.0** (published 2021-10-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install @amphibian/write-cookie
pnpm add @amphibian/write-cookie
yarn add @amphibian/write-cookie
bun add @amphibian/write-cookie
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-10-11 |
| First published | 2016-08-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Thomas Lindstrom |
| Maintainers | thomaslindstr_m |

## Links

- npm: https://www.npmjs.com/package/@amphibian/write-cookie
- Repository: https://gitlab.com/thomaslindstr_m/write-cookie
- Homepage: https://gitlab.com/thomaslindstr_m/write-cookie#README
- Issues: https://gitlab.com/thomaslindstr_m/write-cookie/issues
- npm.io page: https://npm.io/package/@amphibian/write-cookie

## Recent versions

- 1.1.0 (latest) — 2021-10-11
- 1.0.1 — 2016-12-14
- 1.0.0 — 2016-08-23

## README

# write-cookie

[![build status](https://gitlab.com/thomaslindstr_m/write-cookie/badges/master/build.svg)](https://gitlab.com/thomaslindstr_m/write-cookie/commits/master)

write browser cookie

```
npm install @amphibian/write-cookie
```

## Arguments

### `name` **String**

Cookie name.

### `value` **String**

Cookie value. Will be URL encoded.

### `options` **Object**

Options for setting the cookie.

- `expiration` **Date**: Cookie expiration date. 1 year from *now* is the default.
- `domain` **String**: Cookie domain. Current hostname without subdomains is the default, eg. `npmjs.org`.
- `path` **String**: Cookie path. `/` is the default.


## Example

```javascript
var writeCookie = require('@amphibian/write-cookie');

// By default, cookies live for a year.
writeCookie('test_cookie', 'test_value');

// This can be overridden using `options`
writeCookie('test_cookie2', 'test_value2', {
    expiration: new Date((new Date()).getTime() + (1000 * 60 * 60)) // 1 hour
});

// By default, the cookie domain is set to the current hostname without
// subdomains included. Override this using the `domains` option
writeCookie('test_cookie3', 'test_value3', {
    domains: 'my-domain.com'
});
```

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