I am just starting to figure out nodejs and I forgot to put in the flag for session support
$ express -s somefolder
Can I run the above command without overwriting anything I already added or changed or do I have to do something else?
it is not as clear as adding a new dependancy (stylus) to package.json and rerun $ npm install
Update:
Session support is now added via the expressjs/session module.
To install:
npm install -save express-session
To use:
import * as session from "express-session";
...
app.use(cookieParser());
app.use(session({ secret: "..." });
Be sure to visit the module on GitHub to get the latest installation and usage instructions.
Original answer:
Just add the session middleware to your Express app.js file.
app.use(express.cookieParser());
app.use(express.session({secret: '1234567890QWERTY'}));
Make sure it comes after the express.cookieParser() call. Also, update the secret value to a random string for security.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With