快递4.0,快递会话与奇怪的警告消息 [英] express 4.0 , express-session with odd warning message

查看:102
本文介绍了快递4.0,快递会话与奇怪的警告消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图通过使用express 4.x设置一个nodejs应用程序。在绊倒中间件删除问题之后,我终于得到了它的工作。



但是,在下面的代码行中有一些警告消息:

  app.use(session({secret:'< mysecret>'})
pre>

这些警告是:

  Sun,29 Jun 2014 12 :45:10 GMT express-session不建议使用pass resave选项;默认值将在lib\config\express.js中更改:55:11 

Sun,29 Jun 2014 12:45:10 GMT express-session已弃用传递saveUninitialized选项;默认值将在lib\config\express.js中更改:55:11

在文档中,重新保存和saveUninitialized的默认值为true。



所以,将代码更改为

  app.use(session({secret:'< mysecret>',
saveUninitialized:true,
resave:true}));

摆脱了警告。



所以,要解决这个问题:



为什么我必须传递这些值,如果它们是默认值,为什么我不需要传递其他选项?

解决方案

正如警告所示,默认值将发生变化,因此他们希望通过立即设置值来确保在默认值更改时不会遇到意外行为不久的将来)。


I am trying to work through setting up a nodejs app using express 4.x. After stumbling through the middleware-removal issues, I finally got it working.

however, there was a couple of warning messages in the following line of code :

app.use(session({secret: '<mysecret>'})

these warnings were :

Sun, 29 Jun 2014 12:45:10 GMT express-session deprecated pass resave option; default value will change at lib\config\express.js:55:11

Sun, 29 Jun 2014 12:45:10 GMT express-session deprecated pass saveUninitialized option; default value will change at lib\config\express.js:55:11

in the documentation, the default values for resave and saveUninitialized are true.

so, changing the code to read

app.use(session({secret: '<mysecret>', 
                 saveUninitialized: true,
                 resave: true}));

got rid of the warnings.

So, to get to the point of the question:

why should I have to pass these values in if they are the default values, and why don't I have to pass in the other options ?

解决方案

As the warnings say, the default values will change so they want to ensure that by setting the values explicitly now, you won't run into unexpected behavior when the defaults do change (in the near future).

这篇关于快递4.0,快递会话与奇怪的警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆