+if (!process.env.ZOMBOCOM_SESSION_SECRET) {
+ console.log("Error: Environment variable ZOMBOCOM_SESSION_SECRET not set.");
+ console.log("Please set it to a random, but persistent, value.")
+ process.exit();
+}
+
+const session_middleware = session(
+ {store: new FileStore,
+ secret: process.env.ZOMBOCOM_SESSION_SECRET,
+ resave: false,
+ saveUninitialized: true
+ });
+
+app.use(session_middleware);
+
+// convert a connect middleware to a Socket.IO middleware
+const wrap = middleware => (socket, next) => middleware(socket.request, {}, next);
+
+io.use(wrap(session_middleware));
+