react-cookie

Get cookie with react

ε祈祈猫儿з 提交于 2019-12-06 19:06:36
问题 I need to know if my user is connected or not. For that I want to read the cookies that I set in the server side with express-session : app.use(session({ secret: 'crypted key', resave: false, saveUninitialized: true, cookie: { secure: false } // Put true if https })) app.post('/connect_user', (req, res) => { req.session.cookie.username = req.body.username findUserData('username', req.body.username, req, (userData) => { req.session.cookie.id = userData.id req.session.cookie.username = userData

Get cookie with react

此生再无相见时 提交于 2019-12-04 22:53:14
I need to know if my user is connected or not. For that I want to read the cookies that I set in the server side with express-session : app.use(session({ secret: 'crypted key', resave: false, saveUninitialized: true, cookie: { secure: false } // Put true if https })) app.post('/connect_user', (req, res) => { req.session.cookie.username = req.body.username findUserData('username', req.body.username, req, (userData) => { req.session.cookie.id = userData.id req.session.cookie.username = userData.username res.redirect('/profil') }) }) I tried to use react-cookie but it doesn't work however I copy