Returns the session the middleware loaded for this request.
The request context
The session for this request
If SessionPlugin is not registered
SessionPlugin
If the session middleware did not run
app.router.post('/cart', (ctx) => { const session = getSession(ctx); session.set('cartId', 'c-123'); return ctx.response.json({ ok: true });}); Copy
app.router.post('/cart', (ctx) => { const session = getSession(ctx); session.set('cartId', 'c-123'); return ctx.response.json({ ok: true });});
// Reaching the session from a React Router loader (Milestone 44):ReactRouterPlugin({ build, populateLoadContext: (ctx, context) => { context.set(sessionContext, getSession(ctx)); },}); Copy
// Reaching the session from a React Router loader (Milestone 44):ReactRouterPlugin({ build, populateLoadContext: (ctx, context) => { context.set(sessionContext, getSession(ctx)); },});
0.2.0
Returns the session the middleware loaded for this request.