Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 5 days 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 (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-24T21:38:18.000Z (about 1 year ago)
- Last Synced: 2024-10-11T01:11:42.156Z (27 days ago)
- Topics: cookie, cookies, javascript, javascript-library, web
- Language: HTML
- Homepage: http://cookie-manager.zakweb.dev/
- Size: 27.3 KB
- Stars: 1
- 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)