Skip to content

bukinoshita/react-cookies

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

react-cookies

Load and save cookies with React

Install

$ 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.

Type: object

  • expire: Indicates the maximum lifetime of the cookie represented as the date and time
  • maxAge: Indicates the maximum lifetime of the cookie represented as the number of seconds
  • domain: Specifies those hosts to which the cookie will be sent
  • path: The scope of each cookie is limited to a set of paths
  • secure: Limits the scope of the cookie to "secure" channels (where "secure" is defined by the user agent)
  • httpOnly: 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