How can i use redis and express session for multiple website?

Viewed 20

Currently, I'm using redis session for A and B website. A website made by php which i didn't make and B website is my website made by node.js. And I'm trying to share redis session from A website. It's possible to get redis session information from A website to B website(mine). However, when i got session from A website , then TTL become 2 or expired. but when i tried to login B website(mywebsite) and going to A website then it's totally fine. I want to know how to get redis session properly from A website. And I want to know if my setting is wrong for the process.

here is setting for redis session in App.js (B website).

let RedisStore = redisConnect(session);

const mongoUrl = process.env.CONNECTION_URL;

let redisClient = createClient({
  legacyMode: true,
  url: redis_url,
  password: redis_password,
});

const corsOption = {
  credentials: true,
  origin: sso_client_redirect,
};

const PORT = process.env.PORT || 5000;

var app = express();

app.use(cookieParser());
app.use(cors(corsOption));
app.use(express.urlencoded({ limit: "50mb", extended: true }));
app.use(express.json({ limit: "50mb" }));


redisClient.connect().catch(console.error);

///redis 
app.use(
  session({

    store: new RedisStore({
      client: redisClient,
      prefix: redis_prefix,
      ttl: 3600 * 3, 
    }),
    name: redis_session_name,
    secret: redis_session_secret,
    resave: true,
    saveUninitialized: false,
    cookie: {
      path: "/",
      httpOnly: true,
      secure: false,
      domain: redis_domain,
      maxAge: 12 * 60 * 60 * 1000, 
      sameSite: "lax",
    },
  })
);

0 Answers
Related