Currently, I have two separate node applications running on two different ports but having the same data store. I need to exchange user sessions between two applications so that when a user logs into one application, their session is available and they seem to be logged into another application. In this case, it is a โpublic website and administrative serverโ.
Our setup is as follows:
- node with expression
- a passport is used for authorization with a local strategy.
- we use connect-redis so we can share sessions through redis.
- our domains look like this: www.mydomain.com and adm.mydomain.com
The configuration for the session files (and redis) is the same for both applications:
session: { options: { secret: "my secret", cookie: { domain: "mydomain.com", maxAge:1000*60*60*24 } }, redis: { host: 'my host', maxAge: 86400000, secret: "my secret" } }
The configuration for the session files in app.js looks like this:
if ( app.settings.env === "production" ) { session.options.store = new RedisStore(session.redis); } app.use(express.session(session.options)); app.use(passport.initialize()); app.use(passport.session({ secret: 'a different secret' }));
What do I expect from this. . Let us see the same session ID in a cookie between two applications.
So my question is: how do I set up express, redis and passport so that you can conduct sessions on different subdomains?
jpittman
source share