I have been doing web design for a while but, I never have to create cookies, I know the cookie value has to be a string, how can I take an object to set cookies on Javascript.
Asked
Active
Viewed 56 times
0
-
This post [Pure Javascript - store object in cookie](https://stackoverflow.com/questions/11344531/pure-javascript-store-object-in-cookie) might be what you're looking for. Also may be a duplicate :D – Adan Rehtla Jun 04 '19 at 04:30
-
Possible duplicate of [Pure Javascript - store object in cookie](https://stackoverflow.com/questions/11344531/pure-javascript-store-object-in-cookie) – FZs Jun 04 '19 at 04:43
-
Use `JSON.stringify()` and `JSON.parse()` on reparsing – FZs Jun 04 '19 at 04:45
1 Answers
0
Yes you can take an object.
res.cookie('token', jwtToken, { httpOnly: true, secure: true, maxAge:900000 })

codeforbetter
- 16
- 1