How to access a browser cookie in a react app

后端 未结 4 711
你的背包
你的背包 2021-02-10 20:43

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

4条回答
  •  不知归路
    2021-02-10 21:27

    You can start by npm install react-cookiethen import { Cookies } from 'react-cookie' and finally cookies.get('connect.sid'):

    don't forget to wrap your root app inside CookiesProvider something like so :

      
        
      
    

    You can find an example here

提交回复
热议问题