1.0.0 • Published 3 years ago

@vessp/cookie v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

@vessp/cookie

Browser cookie CRUD helper

Installation

npm install --save @vessp/cookie

Usage

  import Cookie from '@vessp/cookie'

  Cookie.set('pool', '6', {
    // Scope
    domain: 'aiur.com',               // default: undefined
    path: '/hatch',                   // default: '/'
    sameSite: 'lax',                  // [ strict | lax | none ], default: undefined
    secure: true,                     // default: true
    
    // Expiry
    expires: new Date().toUTCString() // date when the cookie should expire, default: undefined
    maxAge: 24 * 60 * 60,             // expires in <maxAge> seconds, default: undefined
  })

  // Cookie.get(name) returns cookie value string
  Cookie.get('pool')
  Cookie.get('pool', {
    path: '/hatch',
    domain: 'aiur.com',
  })

  // Cookie.has(name) returns boolean
  Cookie.has('pool')

  // Cookie.remove(name, { domain, path })
  Cookie.remove('pool', {
    domain: 'aiur.com',
    path: '/hatch',
  })

Notes

1.0.0

3 years ago