Cookie

request.cookie.set(name,value,options)

  • Set a cookie, allowing the following parameters, name name, value value, options options, default to the following parameters
{
    path:'/',
    ttl:24 * 60 * 60 * 1000,
    isSecure: false,
    isHttpOnly: true,
    clearInvalid: true,
    encoding: 'base64json',
}

request.cookie.get(name)

  • Get a cookie

request.cookie.del(name)

  • Delete a cookie

Example:

export default async (request)=>{
    const {set,get,del} = request.cookie;
    const name = 'token'
    await set(name,'123456456',{path:'/'});
    // await del(name)
    return await get(name) || 'no cookie' 
}

Next step

Middleware