-
-
Notifications
You must be signed in to change notification settings - Fork 996
Open
Labels
Description
I noticed that changing the configuration in production/deployed mode of express-session cookies can lead to duplicate connect.sid cookie stored in the browser with the old and the new configuration - which can be very problematic to retrieve the right session afterwards.
New configuration :
store: redisStore,
secret: envConfig.OTHER_TOKEN_SECRET,
resave: false,
saveUninitialized: true,
cookie: {
secure: envConfig.ENV === 'local' ? false : true,
httpOnly: true,
sameSite: envConfig.ENV === 'local' ? 'lax' : 'none',
maxAge: 60 * 60 * 1 * 1000, // 1 hour
partitioned: envConfig.ENV === 'local' ? false : true,
},
Old configuration :
store: redisStore,
secret: envConfig.OTHER_TOKEN_SECRET,
resave: false,
saveUninitialized: true,
cookie: {
secure: true,
httpOnly: true,
sameSite: envConfig.ENV === 'local' ? 'lax' : 'none',
},
To fix this, I had no choice but to change the name of the session cookie stored in the browser.
