sd-browser-cookie

水滴前端cookie库

Usage no npm install needed!

<script type="module">
  import sdBrowserCookie from 'https://cdn.skypack.dev/sd-browser-cookie';
</script>

README

cookie

Cookie存储工具

Usage

const cookie = require('sd-browser-cookie');

// 保存cookie
cookie.set('key', value, option)
cookie.set({
  'key1': value1,
  'key2': value2
}, option)

// option

{
  expires: 7, // 过期时间, 支持number、Date、时间字符串
  path: '',
  domain: '',
  secure: true
}

// 获取cookie
cookie.get('key')

// 获取所有cookie对象
cookie.all()

// 删除cookie
cookie.remove('key')

// 清除所有cookie
cookie.clear()