https://github.com/gigabyte5671/cookiemanager
An incredibly simple and lightweight library for adding, fetching, modifying, and removing browser cookies.
https://github.com/gigabyte5671/cookiemanager
cookie cookies javascript javascript-library web
Last synced: about 1 year ago
JSON representation
An incredibly simple and lightweight library for adding, fetching, modifying, and removing browser cookies.
- Host: GitHub
- URL: https://github.com/gigabyte5671/cookiemanager
- Owner: Gigabyte5671
- Created: 2021-04-21T12:59:10.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-10-24T21:38:18.000Z (over 2 years ago)
- Last Synced: 2025-04-03T11:16:38.902Z (about 1 year ago)
- Topics: cookie, cookies, javascript, javascript-library, web
- Language: HTML
- Homepage: http://cookie-manager.zakweb.dev/
- Size: 27.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

CookieManager.js
========
#### JavaScript Cookie Manager ####
[Demo](https://cookie-manager.zakweb.dev/)
An incredibly simple and lightweight library for creating, reading, updating, and deleting browser cookies.
### Usage ###
Include:
```html
```
Or download the zip from the releases page.
To create a cookie, call the setCookie() function with arguments for the cookie name, the value, and the lifespan (in days).
(To update a cookie, just call setCookie() again with the same name and the new value)
```javascript
setCookie(cookieName, cookieValue, cookieLifespan);
```
To retrieve the value of a cookie, call the getCookie() function with an argument for the cookie name. This will return the value of the cookie as a string.
```javascript
var cookieValue = getCookie(cookieName);
```
To check if a cookie exists, call the checkCookie() function with an argument for the cookie name. This will return boolean true if the cookie exists, and boolean false if it doesn't.
(This function is faster than getCookie if you don't need to know the cookie's value)
```javascript
var cookieExists = checkCookie(cookieName);
```
Finally, to remove a cookie, call the clearCookie() function with an argument for the cookie name.
```javascript
clearCookie(cookieName);
```
*Note: Most browsers enforce a maximum size of 4096 bytes per cookie. Attempting to set or update a cookie with a value larger than that will fail without returning an error.*
### Other ###
[Cookies icon by Icons8](https://icons8.com/icon/12878/cookies)