https://github.com/delfimov/js-cookie
Javascript cookie library
https://github.com/delfimov/js-cookie
cookie cookies javascript javascript-cookie-library js-cookie vanilla-javascript
Last synced: about 1 year ago
JSON representation
Javascript cookie library
- Host: GitHub
- URL: https://github.com/delfimov/js-cookie
- Owner: delfimov
- License: mit
- Created: 2012-02-21T14:12:37.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2017-07-31T14:21:58.000Z (almost 9 years ago)
- Last Synced: 2025-04-14T20:18:52.977Z (about 1 year ago)
- Topics: cookie, cookies, javascript, javascript-cookie-library, js-cookie, vanilla-javascript
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JS-Cookie
Javascript Cookie library
## Install
```
npm install js_cookie
```
## Usage
```javascript
value = cookie.get(name);
```
`name` - cookie name
returns cookie value or null if not set
```javascript
cookie.set(name, value, expires, path, domain, secure);
```
`name` - cookie name
`value` - string value
`expires` - days before expire. If omitted, the cookie will expire at the end of the session (when the browser closes).
`path` - The path on the server in which the cookie will be available on. The default value is the current directory that the cookie is being set in.
`domain` - The domain that the cookie is available to. Cookies available to a lower domain, such as 'example.com' will be available to higher subdomains, such as 'www.example.com'.
`secure` - Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client. Default is false.
```javascript
cookie.remove(name);
```
`name` - cookie name
```javascript
cookie.isEnabled();
```
`true` or `false`