This question is a bit popular but Im not having such luck. Im mostly a backend person so Im learning as I go along.
I have a cookie named connect.sid
and v
Using react-cookie
may be the easiest way to get cookie value. You can run npm install react-cookie
, the v2 will be installed. If you only want to use a simple API only on the client, i will suggest to use v1. Just run npm install react-cookie@1.0.5
, add import cookie from 'react-cookie'
to you file and use cookie.load('connect.sid')
to get cookie value. You can check the README of v1 for detail.
If you still cannot get the cookie value, please confirm:
/
, if you want your cookie to be accessible on all pages.