Files
main.tsmain
What you'll learn
- Set a cookie with setCookie() from hono/cookie and choose its attributes: httpOnly, path, sameSite, maxAge
- Read one cookie with getCookie(c, name) and all of them with getCookie(c)
- Delete a cookie with deleteCookie(), which is a Set-Cookie that expires it, and see the jar in the request panel follow
Press Run tests to start the app. Its log appears here.Graded endpoints
No session cookie yet: getCookie() gives undefined and the route answers 401
No theme cookie: the default
setCookie() puts a Set-Cookie header on the response; the runtime's jar keeps it, as a browser would
The session cookie came back with the request and getCookie() reads the user from it
A second cookie, with a maxAge so it outlives the session
getCookie(c) with no name is every cookie the request carried
deleteCookie() answers a Set-Cookie with Max-Age=0, which removes the session cookie from the jar
The session cookie is gone, so it is 401 again
Only the session cookie was deleted; the preference is still there
What the jar still holds after logout