Permalink
Browse files

added more to the connect example

  • Loading branch information...
1 parent d4ad1f5 commit 954d6e96b43d50f2b2b83cd1bad0408ddda00223 @tj committed Apr 15, 2011
Showing with 14 additions and 3 deletions.
  1. +14 −3 examples/connect.js
View
@@ -13,15 +13,26 @@ var connect = require('connect')
nedis.createServer().listen();
+// session options
+
+var options = {
+ store: new RedisStore
+ , secret: 'whatever'
+ , cookie: {
+ maxAge: 60000
+ }
+};
+
// connect server
connect(
connect.favicon(),
connect.cookieParser(),
- connect.session({ store: new RedisStore, secret: 'whatever' }),
+ connect.session(options),
function(req, res){
req.session.hits = req.session.hits || 0;
- var n = req.session.hits++;
- res.end('viewed ' + n + ' times');
+ var n = req.session.hits++
+ , maxAge = req.session.cookie.maxAge;
+ res.end('viewed ' + n + ' times, expires in ' + (maxAge / 1000) + ' seconds');
}
).listen(3000);

0 comments on commit 954d6e9

Please sign in to comment.