Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/therohantomar/jscookie
thejscookie is a simple JavaScript library for working with cookies in the browser. It provides a set of functions to easily set, get, and remove cookies.
https://github.com/therohantomar/jscookie
cookie datastorage getcookie js jscookie json nodejs npm npm-package setcookies
Last synced: about 1 month ago
JSON representation
thejscookie is a simple JavaScript library for working with cookies in the browser. It provides a set of functions to easily set, get, and remove cookies.
- Host: GitHub
- URL: https://github.com/therohantomar/jscookie
- Owner: therohantomar
- Created: 2023-09-27T15:40:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-28T12:52:57.000Z (over 1 year ago)
- Last Synced: 2024-05-02T17:05:21.831Z (8 months ago)
- Topics: cookie, datastorage, getcookie, js, jscookie, json, nodejs, npm, npm-package, setcookies
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/thejscookie
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# thejscookie
`thejscookie` is a simple JavaScript library for working with cookies in the browser. It provides a set of functions to easily set, get, and remove cookies.
## Installation
You can install `thejscookie` via npm or yarn.
### Using npm
```bash
npm install thejscookie
```
### Using Yarn```bash
yarn add thejscookie
```## Usage
### To use thejscookie, you can import it and access its methods as follows:```bash
import thejscookie from 'thejscookie';// Set a cookie with a name, value, and expiry days
thejscookie.set('myCookie', 'cookieValue', 7);// Get a cookie by name
const cookieValue = thejscookie.get('myCookie');// Remove a cookie by name
thejscookie.remove('myCookie');
```## Methods
- set(name, value, expiryDays)
Sets a cookie with the given name, value, and optional expiryDays. If expiryDays is not provided, the cookie will be session-only.- get(name)
Gets the value of a cookie with the specified name. Returns null if the cookie does not exist.- remove(name)
Removes a cookie with the specified name.For any inquiries or feedback, feel free to contact the author: [therohantomar](mailto:[email protected])