Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 6, 2024 via pnpm

js-cookie 3.0.5

A simple, lightweight JavaScript API for handling cookies
Package summary
Share
0
issues
1
license
1
MIT
Package created
15 Apr 2015
Version published
24 Apr 2023
Maintainers
2
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
js-cookie@3.0.5
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of js-cookie 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does js-cookie do?

JS-Cookie is a simple, lightweight JavaScript API for managing cookies. This robust and easy-to-use tool allows users to create, read, and delete cookies. Moreover, it supports all types of characters and it's thoroughly tested. The API also does not rely on any other JavaScript libraries, meaning it can be used standalone. All these features come in under 800 bytes when gzipped, making JS-Cookie ultra-lightweight, yet highly powerful and practical.

How do you use js-cookie?

JS-Cookie has a very straightforward usage pattern. Here's how to use it:

To install JS-Cookie, use npm as follows:

npm i js-cookie

You may include it from a CDN like jsDelivr too.

Creating a simple cookie that will be valid across your entire website looks like this:

Cookies.set('name', 'value');

To create a cookie that expires in 7 days and is valid across the entire site:

Cookies.set('name', 'value', { expires: 7 });

If a cookie is to be valid to the path of the current page:

Cookies.set('name', 'value', { expires: 7, path: '' });

Reading cookies is done with:

Cookies.get('name'); // Returns 'value'
Cookies.get('nothing'); // Returns undefined

All visible cookies can be read with:

Cookies.get(); // Returns { name: 'value' }

Removing cookies:

Cookies.remove('name');

More complex usage scenarios include changing the default cookie attributes and encoding or decoding the cookie values. Instructions for these can be found in the JS-Cookie documentation.

Where are the js-cookie docs?

The comprehensive documentation for JS-Cookie can be found in the project's GitHub repository README file. It discusses everything from basic usage to advanced topics like using custom encoding/decoding converters and managing potential namespace conflicts. For more specific use cases, there's also a useful wiki linked in the README. Anyone looking to dive into the fully detailed inner workings of the JS-Cookie API can navigate to the latest release documentation from the main branch of the GitHub repository.