Step 15
Notice when we redirect to dashboard, we pass the username as query parameter:
res.redirect(`/dashboard?username=${user.username}`);
We can now change this to instead use a cookie to store username.
res.cookie("username", user.username).redirect(`/dashboard`);
Also, update update the route handler for dashboard
so that you read the username
from set cookie:
- const username = req.query.username;
+ const username = req.cookies.username;
Save index.js
. Go to the application and login. Make sure the dashboard view works as intended.