使用NodeJS和ExpressJS为域设置Cookie而不是子域

我一直在使用expressjs和mongostore进行会话pipe理。 以下是在expressjs中configuration商店的代码,

app.configure(function(){ app.use(express.session({ secret: conf.secret, maxAge: new Date(Date.now() + 3600000), cookie: { path: '/' }, store: new MongoStore(conf.db) })); }); 

我在上面的代码中提到了cookie的path。 但是它将cookie设置为sub.domain.com而不是.domain.com。 我如何做到这一点?

像这样configuration它:

 app.use(express.session({ secret: conf.secret, cookie: { domain:'.yourdomain.com'}, store: new MongoStore(conf.sessiondb) })); 

尝试使用以下链接进行configuration。

 res.cookie('name', 'tobi', { domain: '.example.com', path: '/admin', secure: true }); 

链接: http //expressjs.com/api.html#res.cookie