koa-cookie
Lightweight Koa-Middleware for Cookies
Complete Example
const Koa = cookie = router = const app = port = 3000 app app app
Documentation
cookies
Array
~ The Cookie Parser sets an array ctx.request.cookies
with the cookies that where sent with the request.
Example
Let's say we get a cookie (Foo=Bar;
) We can access it in the context of Koa like this: ctx.request.cookies['Foo']
=> "bar"
cookie
Element
~ The Parser also defines a getter and setter for cookies
Example
// Set a cookiectxrequestcookie
Options | Value |
---|---|
Key | Cookie Name |
Value | Cookie Value |
Path | Url Path |
Domain | Sub or Domain |
httpOnly | bool |
secure | bool |
max-age | seconds after the cookie expres |
// Get a cookiectxrequestcookie "12345678"