# qiao.cookie.js

> document cookie tools

Latest version **3.7.5** (published 2025-06-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install qiao.cookie.js
pnpm add qiao.cookie.js
yarn add qiao.cookie.js
bun add qiao.cookie.js
```

## Health

**Score 40/100 (D)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 3.7.5 |
| Published | 2025-06-30 |
| First published | 2022-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | uikoo9 <uikoo9@qq.com> |
| Maintainers | npm_insistime |
| Keywords | cookie |

## Links

- npm: https://www.npmjs.com/package/qiao.cookie.js
- Repository: https://github.com/uikoo9/qiao-web
- Homepage: https://code.vincentqiao.com/#qiao.cookie.js
- Issues: https://github.com/uikoo9/qiao-web/issues
- npm.io page: https://npm.io/package/qiao.cookie.js

## Recent versions

- 3.7.5 (latest) — 2025-06-30
- 3.7.3 — 2024-12-04
- 3.7.0 — 2024-02-17
- 3.5.9 — 2023-10-09
- 3.2.6 — 2023-09-08
- 3.2.0 — 2023-05-30
- 3.1.5 — 2023-05-18
- 3.1.1 — 2023-04-17
- 3.1.0 — 2023-04-17
- 3.0.8 — 2023-04-13
- 1.1.5 — 2023-02-01
- 1.1.4 — 2022-11-30
- 1.1.3 — 2022-11-29
- 1.1.2 — 2022-10-28
- 1.1.1 — 2022-10-25
- … 15 more at https://npm.io/package/qiao.cookie.js/versions

## README

## qiao.cookie.js

[![npm version](https://img.shields.io/npm/v/qiao.cookie.js.svg?style=flat-square)](https://www.npmjs.org/package/qiao.cookie.js)
[![npm downloads](https://img.shields.io/npm/dm/qiao.cookie.js.svg?style=flat-square)](https://npm-stat.com/charts.html?package=qiao.cookie.js)

浏览器 Cookie 相关操作封装，详见：[cookie 文档](https://developer.mozilla.org/zh-CN/docs/Web/API/Document/cookie)

## install

安装

```shell
npm i qiao.cookie.js
```

## use

使用

```javascript
// cjs
const { cookie } = require('qiao.cookie.js');

// mjs
import { cookie } from 'qiao.cookie.js';
```

## api

## keys

返回已经存在的 key 数组

- return
  - 类型: string[]
  - 说明: 已经存在的 key 数组

```javascript
keys();
```

## has

是否已经存在某一个 key

- key
  - 类型: string
  - 说明: key
- return
  - 类型: boolean
  - 说明: 结果，存在返回 true

```javascript
has(key);
```

## cookie

获取，设置，删除数据

- key
  - 类型: string
  - 说明: 只传入 key 时，获取信息
- value
  - 类型: any
  - 说明:
    - 设置信息时，传入 key 和 value
    - 删除信息时传入 null
- options
  - 类型: object
  - 说明: 其他配置项
  - ```javascript
    {
      sPath,
      sDomain,
      vEnd,
      bSecure,
    }
    ```
- return
  - 类型: any
  - 说明: 获取信息是返回 value，其他返回 true 或者非 true

```javascript
// get
cookie(key);

// set
cookie(key, value);

// set options
cookie(key, value, options);

// del
cookie(key, null);
```

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