JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q49580F
  • License MIT

Package Exports

  • @zero-dependency/cookie
  • @zero-dependency/cookie/dist/index.es.js
  • @zero-dependency/cookie/dist/index.umd.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@zero-dependency/cookie) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@zero-dependency/cookie

Installation

npm install @zero-dependency/cookie
yarn add @zero-dependency/cookie
pnpm add @zero-dependency/cookie

Usage

import { cookies } from '@zero-dependency/cookie'

// Create a cookie
cookies.set('name', 'value')

// Create a cookie that expires 7 days from now
cookies.set('name', 'value', { expires: 7 })

// Create an expiring cookie, valid to the path of the current page
cookies.set('name', 'value', { expires: 7, path: '' })

// Read cookie
cookies.get('name')

// Read all visible cookies
cookies.list()

// Delete cookie
cookies.delete('name')

// Delete a cookie valid to the path of the current page
cookies.set('name', 'value', { path: '' })
cookies.delete('name'); // fail!
cookies.delete('name', { path: '' }); // success!

// Cookie attribute defaults can be set globally
cookies.withAttributes({ path: '/', domain: '.example.com' })