To store or access session data, simply use the request property req.session, which is (generally) seri
alized as JSON by the store, so nested objects are typically fine.
一旦我们将express-session中间件用use挂载后,我们可以很方便的通过req参数来存储和访问se
ssion对象的数据。req.session是一个JSON格式的JavaScript对象,我们可以在使用的过程中随意的增
加成员,这些成员会自动的被保存到option参数指定的地方,默认即为内存中去。
connect-mongo uses MongoDB's TTL collection feature (2.2+) to have mongod automatically remove expired sessions. (mongod runs this check every minute.)
Note: By connect/express's default, session cookies are set to expire when the user closes their browser (maxAge: null). In accordance with standard industry practices, connect-mongo will set these sessions to expire two weeks from their last 'set'. You can override this behavior by manually setting the maxAge for your cookies -- just keep in mind that any value less than 60 seconds is pointless, as mongod will only delete expired documents in a TTL collection every minute.