System Information
-
Strapi Version:
3.0.5 -
Operating System:
Ubuntu 20.04 -
Database:
PG -
Node Version:
12.18.2 -
NPM Version:
6.14.5 - Yarn Version:
Hi,
I’m trying to use session variables and in order to do so I’ve enabled this middleware by configuring /config/middleware.js:
module.exports = { settings: { logger: { level: process.env.NODE_ENV === "production" ? "info" : "debug", }, session: { enabled: true }, }, };
- What is the recommended way of using it? ctx.state.session.mySession or ctx.session.mySession?
- I guess that this explicit code is redundant, right? I mean, just enabling it as above is sufficient.
const session = require("koa-session"); const Koa = require("koa"); const app = new Koa(); app.use(session(app));
- Is this the right way of doing it? The reason I’m asking is that on one environment (local) setting a session (either by the 1st example or the 2nd) works as expected while on a different environment (AWS) the values are empty.
Thanks in advance,
Yossi