Created
February 13, 2012 18:24
-
-
Save davidkrisch/1818829 to your computer and use it in GitHub Desktop.
Express Cookie Handling - why does Connect call toLowerCase on all cookie names?
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
var express = require('express'); | |
var app = express.createServer(); | |
app.use(express.cookieParser()); | |
app.get('/', function(req, res) { | |
// Prints undefined | |
process.stdout.write('req.cookies.RelayState = ' | |
+ JSON.stringify(req.cookies.RelayState) + '\n'); | |
// Prints undefined | |
process.stdout.write('req.cookies[\'RelayState\'] = ' | |
+ JSON.stringify(req.cookies['RelayState']) + '\n'); | |
// Prints clever cookie | |
process.stdout.write('req.cookies[\'relaystate\'] = ' | |
+ JSON.stringify(req.cookies['relaystate']) + '\n'); | |
// Prints clevercookie | |
process.stdout.write('req.cookies.relaystate = ' | |
+ JSON.stringify(req.cookies.relaystate) + '\n'); | |
res.cookie('RelayState', 'clevercookie'); | |
res.send('hello world'); | |
process.stdout.write('----------------\n'); | |
process.stdout.write(JSON.stringify(req.cookies) + '\n'); | |
process.stdout.write('----------------\n'); | |
}); | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment