Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

node.js - express 4.0 , express-session with odd warning message

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 libconfigexpress.js:55:11

Sun, 29 Jun 2014 12:45:10 GMT express-session deprecated pass saveUninitialized option; default value will change at libconfigexpress.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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...