cookie-parser-io
v1.0.3
Published
cookie parsing with signatures for socket.io
Downloads
14
Readme
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-io
API
var cookieParser = require('cookie-parser-io')
cookieParser(secret, options)
secret
a string used for signing cookies. This is optional and if not specified, will not parse signed cookies.options
an object that is passed tocookie.parse
as the second option. See cookie for more information.decode
a 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