-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathjs-cookie.javascript.txt
37 lines (31 loc) · 1.8 KB
/
js-cookie.javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
┏━━━━━━━━━━━━━━━┓
┃ JS-COOKIE ┃
┗━━━━━━━━━━━━━━━┛
ALTERNATIVES ==> # - jquery-cookie: use jQuery
# - cookie (preferred with Node): used by Express
# - js-cookie
# - deno cookie (preferred with deno)
VERSION ==> #3.0.5
Cookie.withAttributes(OPTS)
->Cookie #Set default OPTS
OPTS.attributes #Defaults OPTS. Readonly. Def to {}
Cookie.get()->{ VAR: 'VAL' } #
Cookie.get('VAR')->'VAL' #
Cookie.set('VAR', 'VAL'[, OPTS]) #OPTS:
# - domain STR
# - path STR
# - expires DATE|NUM (in days)
# - maxAge NUM (in secs)
# - secure BOOL
# - httpOnly BOOL
# - sameSite 'strict|lax|none'
# - priority 'low|medium|high'
# - paritioned BOOL
Cookie.remove('VAR'[, OPTS]) #Must specify OPTS.path|domain
Cookie.converter #CONVERTER, i.e. OBJ with write|read() called to encode|decode 'VAL'
Cookie.converter.write('VAL')
->'VAL' #Call encodeURIComponent() on =;
Cookie.converter.read('VAL')
->'VAL' #Call decodeURIComponent() on =;
Cookie.withConverter(CONVERTER)
->Cookie #Adds a Cookie.converter (does not remove the default one, done before (on both write|read))