-
-
Save PabloVallejo/5496271 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
// Dependencies. | |
var express = require('express'), | |
app = module.exports = express.createServer(), | |
del = function(req, res) { res.clearCookie('login_token'); res.redirect('/'); }, | |
set = function(req, res) { res.cookie('login_token', +new Date(), { maxAge: 3600000, path: '/' }); res.redirect('/'); }; | |
// Config | |
app.configure(function() { | |
app.use(express.bodyParser()); | |
app.use(express.cookieParser()); | |
app.use(app.router); | |
}); | |
// Routes | |
app.get('/', function home(req, res) { | |
res.end('<a href="/set">set</a> <a href="/del/a">del</a> <a href="/del">rlydel</a>'); | |
console.log(req.cookies); | |
}); | |
app.get('/set', set); | |
app.get('/del/a', del); | |
app.get('/del', del); | |
// Server | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment