pixelplanet/src/core/session.js

31 lines
779 B
JavaScript
Raw Normal View History

2022-04-05 19:37:33 +00:00
/*
*
2020-01-02 16:58:06 +00:00
*/
import expressSession from 'express-session';
2022-06-19 10:51:36 +00:00
import RedisStore from '../utils/connectRedis';
2020-01-02 16:58:06 +00:00
2022-06-19 21:19:10 +00:00
import client from '../data/redis/client';
2020-01-02 16:58:06 +00:00
import { HOUR, COOKIE_SESSION_NAME } from './constants';
import { SESSION_SECRET } from './config';
2022-06-19 21:19:10 +00:00
export const store = new RedisStore({ client });
2020-01-02 16:58:06 +00:00
const session = expressSession({
name: COOKIE_SESSION_NAME,
store,
secret: SESSION_SECRET,
// The best way to know is to check with your store if it implements the touch method. If it does, then you can safely set resave: false
resave: false,
saveUninitialized: false,
cookie: {
path: '/',
httpOnly: true,
secure: false,
// not setting maxAge or expire makes it a non-persisting cookies
maxAge: 30 * 24 * HOUR,
},
});
export default session;