Skip to content

Instantly share code, notes, and snippets.

@jjason685
Created May 1, 2019 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjason685/20d83ab49bff9a40d1d9d41427145bbd to your computer and use it in GitHub Desktop.
Save jjason685/20d83ab49bff9a40d1d9d41427145bbd to your computer and use it in GitHub Desktop.
const express = require('express');
const cookieParser = require('cookie-parser');
const app = express();
app.use(cookieParser());
app.get('/', function (req, res) {
if (req.cookies.default) {
console.log('Received cookie from instance');
res.send('123').status('200');
} else {
console.log('No cookie, sending.');
res.cookie('default', '123', { maxAge: 90000, httpOnly: true }).send('123').status('200');
}
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment