Tiny Cookie Manipulation JavaScript Library – cookieManager.js

Category: Javascript | May 5, 2022
AuthorGigabyte5671
Last UpdateMay 5, 2022
LicenseMIT
Tags
Views997 views
Tiny Cookie Manipulation JavaScript Library – cookieManager.js

cookieManager.js is a super tiny (~1kb minified) cookie manipulation JavaScript library for setting, getting, checking, and clearing cookies in your web browser.

How to use it:

1. Download and import the JavaScript cookieManager.min.js into the document.

<script src="cookieManager.min.js"></script>

2. Create a cookie and pass the following parameters:

  • cookieName: Cookie name
  • cookieValue: Cookie value
  • cookie: Cookie life time in days
// setCookie(cookieName, cookieValue, cookieLifespan);
setCookie('myCookie', 'CSSScript', 1);

3. Get the cookie value by name.

var cookieValue = getCookie('myCookie');

4. Check if a cookie exists.

var cookieExists = checkCookie('myCookie');

5. Remove the cookie.

clearCookie('myCookie');

Changelog:

05/05/2022

  • Several minor improvements

You Might Be Interested In:


Leave a Reply