Tiny Cookie Manipulation JavaScript Library – cookieManager.js

Category: Javascript | May 5, 2022
Author:Gigabyte5671
Views Total:581 views
Official Page:Go to website
Last Update:May 5, 2022
License:MIT

Preview:

Tiny Cookie Manipulation JavaScript Library – cookieManager.js

Description:

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