Skip to content

Instantly share code, notes, and snippets.

@jscalderon65
Created May 2, 2023 19:56
Show Gist options
  • Save jscalderon65/ec4e2e3b2f9e7ac2cccafe4f2cd91eb6 to your computer and use it in GitHub Desktop.
Save jscalderon65/ec4e2e3b2f9e7ac2cccafe4f2cd91eb6 to your computer and use it in GitHub Desktop.
Therefore, cookies are small strings that contain key-value pairs of information sent from the webserver to the browser to get information about the user. The browser will then save them locally. This way, subsequent requests can be made to the server to immediately update user content on the website depending on the previous requests that a use…
app.get('/getcookie', (req, res) => {
//show the saved cookies
console.log(req.cookies)
res.send(req.cookies);
});
app.get('/deletecookie', (req, res) => {
//delete all cookies
res.clearCookie()
res.send('Cookie has been deleted successfully');
});
const cookieSecurity = (req, res, next) => {
res.cookie("HttpOnly", true);
res.cookie("Secure", isProdEnvironment);
next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment