Created
May 1, 2019 13:34
-
-
Save jjason685/20d83ab49bff9a40d1d9d41427145bbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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