expressjs / cookie-parser

Parse HTTP request cookies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to sign a cookie manually?

wzup opened this issue · comments

commented

For the sake of testing, I need to provide a signed cookie with HTTP request. So that, my server can consider it as a signed cookie and put it into req.signedCookies object.

However I cannot find a appropriate method in docs.
I'd like to do the following:

let signed = cookieParser.signYourCookie({ cookieName: 'cookieValue' }, secretString);
// => cookieName=cookieValue.9PuJzypXeGq3tc2fFvlukjgNZ518jk

That is an operation opposite to cookieParser.signedCookie(str, secret) (link)