Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
425 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 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...