The cookie will still be visible, but it has a signature, so it can detect if the client modified the cookie.
It works by creating a HMAC of the value (current cookie), and base64 encoded it. When the cookie gets read, it recalculates the signature and makes sure that it matches the signature attached to it.
If it does not match, then it will give an error.
If you want to hide the contents of the cookie as well, you should encrypt it instead (or just stores it in the server side session). I'm not sure if there is middleware for that already out there or not.
Edit
And to create a signed cookie you would use
res.cookie('name', 'value', {signed: true})
And to access a signed cookie use the signedCookies
object of req
:
req.signedCookies['name']
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…