node.js - node express how to get client cookie
ringa_lee
ringa_lee 2017-06-24 09:43:18
0
1
1054

The user enters the domain name. If he has logged in before, he will go directly to the homepage. Otherwise, he will jump to the login interface because after logging in, I save the username in the cookie. Now I want to use cookies to determine if the user is logged in or not.

ringa_lee
ringa_lee

ringa_lee

reply all(1)
typecho

Introducing the cookie-parser package.

const app = express();
...
const cookieParser = require('cookie-parser');
app.use(cookieParser());
...

Then you should be able to use req.cookies in the routing to get the cookie object

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template