Skip to content

A complete cookies reader/writer framework with full unicode support.

License

Notifications You must be signed in to change notification settings

mozmeao/cookie-helper

Repository files navigation

Mozilla Cookie Helper

What does it do?

A complete cookies reader/writer framework with full unicode support. For more general information on web Cookies visit MDN.

How to install and use

Install via npm: npm install @mozmeao/cookie-helper

Import the library at your applications entrypoint via require, import or by using a global variable in your script tag::

  • import CookieHelper from '@mozmeao/cookie-helper';
  • const CookieHelper = require('@mozmeao/cookie-helper')
  • const CookieHelper = window.CookieHelper

Once that object is instanciated you can use the following functions:

Function Notes
CookieHelper.setItem(name, value[, end[, path[, domain[, secure[, samesite]]]]]) will set a cookie inside of document.cookie If the cookie is created it will return true otherwise, false
CookieHelper.getItem(name) Will return the key that you pass to the function, if not found or no argument was passed - will return null
CookieHelper.removeItem(name[, path[, domain]]) Will remove the cookie that matches the passed key. If no key is found, it will return false. If key is found, it will set the cookie to expire immediately and then return true
CookieHelper.hasItem(name) Will return true if cookie is found that matches the passed key. If no key is found it will return false
CookieHelper.keys() Will return an array of the keys found in document.cookie

Further Doumentation

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.

About

A complete cookies reader/writer framework with full unicode support.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •