No notes yet. Add one to create the cookie.
Signed cookies and CSRF tokens
Cookies are stored in the browser, so visitors can edit them. A signed cookie tells the server whether its value is still the one it wrote.
With a secret configured for @fastify/cookie in jeasx.config.js, a route can set a cookie with { signed: true }: its value gets a signature, which request.unsignCookie() checks.
A guard protects all forms of this example against cross-site request forgery: it stores a random token in a signed cookie and only accepts forms which send the same token in a hidden field. Have a look at the source to see how it works.