N
N
Nikita Reshetnyak2019-08-20 13:00:52
Node.js
Nikita Reshetnyak, 2019-08-20 13:00:52

How to work with express-session on subdomains?

Good afternoon. There was a need to use the current user session on the subdomains of the site.
express-session is configured like this:

app.use(session({
    secret: config.app.secret,
    store: myStore,
    resave: true,
    proxy: true,
    saveUninitialized: true,
    cookie: {
      expires: 18000000,
      originalMaxAge: 18000000,
      domain: ".domain.com"
    },
    maxAge: 18000000
  }));

But it doesn't give any results. I looked at the cookies through the browser plugin Cooker Editor, the domain field is indicated as .domain.com, but the session is not available for the subdomain.
PS On the subdomain, I also have express-session and connect-session-sequelize connected

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Reshetnyak, 2019-08-22
@MeG1tsune

Hah, stupid mistake on my part, including the file where the sessions are located and the API was lower than the routing index, because of which the session was not accepted. Problem solved

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question