1.0.3 • Published 11 years ago
cookie-parser-io v1.0.3
cookie-parser-io
cookies parser for socket.io inspired by cookie-parser
Parse Cookie header and populate req.cookies with an object keyed by the cookie
names. Optionally you may enable signed cookie support by passing a secret string,
which assigns req.secret so it may be used by other middleware.
Install
$ npm install cookie-parser-ioAPI
var cookieParser = require('cookie-parser-io')cookieParser(secret, options)
secreta string used for signing cookies. This is optional and if not specified, will not parse signed cookies.optionsan object that is passed tocookie.parseas the second option. See cookie for more information.decodea function to decode the value of the cookie ned cookie and the signature is valid, the key will be deleted from the object and added to the new object that is returned.
Example
var cookieParser = require('cookie-parser-io');
var io = require('socket.io').listen(server);
io.use(cookieParserIO('secret word'));
io.on('connection', ...);//retrieve cookies like this var id = socket.request.signedCookies.uid; var token = socket.request.signedCookies.auth_token;
License
MIT