Has support for sessions been removed from express or is there a new command? I cant seem to find an answer anywhere. This is the result of me trying to use it.
Last login: Fri Jun 20 14:42:17 on ttys001
new-host-2:~ Brennan$ cd Desktop/
new-host-2:Desktop Brennan$ mkdir test6
new-host-2:Desktop Brennan$ cd test6
new-host-2:test6 Brennan$ express -s
error: unknown option `-s'
new-host-2:test6 Brennan$
Yes, you're correct. Many middlewares had been removed from express 4 including session. Therefore, -s is no longer part of the express command. Here are some of the middlewares removed:
basicAuth()
bodyParser()
compress()
cookieParser()
cookieSession()
csrf()
directory()
Here is an example how to add session support to express 4 with cookie-session middeware:
var express = require('express');
var session = require('cookie-session');
var app = express();
app.use(session({
keys: ['key1', 'key2'],
secureProxy: true // if you do SSL outside of node
}));
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