Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bukinoshita/react-cookies
:cookie: Load and save cookies with React
https://github.com/bukinoshita/react-cookies
cookie cookies react react-cookie react-cookies
Last synced: 12 days ago
JSON representation
:cookie: Load and save cookies with React
- Host: GitHub
- URL: https://github.com/bukinoshita/react-cookies
- Owner: bukinoshita
- License: mit
- Created: 2017-05-04T23:22:09.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2023-01-06T01:41:33.000Z (almost 2 years ago)
- Last Synced: 2024-10-10T16:07:18.772Z (29 days ago)
- Topics: cookie, cookies, react, react-cookie, react-cookies
- Language: TypeScript
- Homepage:
- Size: 1010 KB
- Stars: 129
- Watchers: 2
- Forks: 9
- Open Issues: 14
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# react-cookies
> Load and save cookies with React
## Install
```bash
$ yarn add react-cookies
```## API
### .setCookie(name, value, [options])
Set a cookie.
#### name
The cookie name
Type: `string`
Required#### value
The cookie value
Type: `any`
Required#### options
Support all the cookie options from the [RFC 6265](https://tools.ietf.org/html/rfc6265#section-4.1.2.1).
Type: `object`
- [expire](https://tools.ietf.org/html/rfc6265#section-4.1.2.1): Indicates the maximum lifetime of the cookie represented as the date and time
- [maxAge](https://tools.ietf.org/html/rfc6265#section-4.1.2.2): Indicates the maximum lifetime of the cookie represented as the number of seconds
- [domain](https://tools.ietf.org/html/rfc6265#section-4.1.2.3): Specifies those hosts to which the cookie will be sent
- [path](https://tools.ietf.org/html/rfc6265#section-4.1.2.4): The scope of each cookie is limited to a set of paths
- [secure](https://tools.ietf.org/html/rfc6265#section-4.1.2.5): Limits the scope of the cookie to "secure" channels (where "secure" is defined by the user agent)
- [httpOnly](https://tools.ietf.org/html/rfc6265#section-4.1.2.6): Limits the scope of the cookie to HTTP requests### .getCookie(name)
Get a cookie.
#### name
The cookie name.
Type: `string`
Required### .removeCookie(name)
Remove a cookie.
#### name
The cookie name.
Type: `string`
Required### .getAllCookies()
Get all cookies.
## License
MIT © [Bu Kinoshita](https://bukinoshita.com)