-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (26 loc) · 697 Bytes
/
app.js
File metadata and controls
35 lines (26 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var express = require('express');
var session = require ('express-session');
var MongoDBStore = require('connect-mongodb-session')(session);
var app = express()
var store = new MongoDBStore({
uri:'mongodb://localhost:27017/TradeStuffSessions',
collection: 'Sessions'
});
store.on('connected', function() {
store.client;
});
store.on('error', function(error) {
assert.ifError(error);
assert.ok(false);
});
app.use(require('express-session')({
secret: 'This is a secret',
cookie: { maxAge: 1000 * 60 * 5 },
store: store,
resave: true,
saveUninitialized: true
}));
app.get('/', function(req, res) {
res.send('Hello' + JSON.stringify( req.session));
});
server = app.listen(3000);