Comments (9)
express-session
's dependency on cookie-parser
has been removed. That message should come up when the cookie isn't available in req.headers.cookie
.
Is your app still working, as you would expect?
What version of express are you using?
from session.
The app is still working as expected. I'm using express 4.5.1 and express-session 1.6.4
from session.
Can you post a gist that reproduces the issue?
from session.
I found the issue (I'm relatively new to express). I had not declared req.headers.cookie. I added a line
req.headers.cookie = null;
and that solved the issue. I guess it was not able to access it because it didn't exist. Thanks for your time.
from session.
Its strange that req.headers.cookie = null;
solves your issue. the deprecated message should only show up if the cookie is not available at req.headers.cookie
, but was available in req.cookies
, or req.signedCookies
.
from session.
Here's the relevant snippet from my app.js. As I said I'm new to express so I may have a glaring mistake I just don't have the intuition to catch.
app.use(function(req, res, next) {
req.db = db.db;
req.encoder = new Encoder('entity');
req.session = null;
req.headers.cookie = null;
next();
});
app.use(partials());
app.use(cookieParser());
app.use(session({
secret: ''+new Date().getTime(),
cookie: {secure: false},
resave: true,
saveUninitialized: true
}));
app.set('port', process.env.PORT || defaultPort);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: 'false'}));
app.use(express.static('public'));
app.use(express.static(path.join(__dirname, 'public')));
from session.
You shouldn't be doing anything to req.session
, or req.headers.cookie
directly.
You should be able to remove the cookieParser()
middleware. Unless you need is for something else, and then you can put it after the session middleware.
from session.
The warning is because your secret is ''+new Date().getTime()
, so it is different every time you restart the server and it's confusing the internals of this module. Your secret needs to be static. Also, remove app.use(cookieParser());
Its strange that req.headers.cookie = null; solves your issue
@joewagner it made the issue so away because it removed the cookies, essentially, so the module was no longer confused from having an invalid secret.
from session.
Thanks for the help!
from session.
Related Issues (20)
- express-session sometimes saves empty sessions (very rarely) HOT 6
- Need to access session object for the session to save or set cookies? HOT 2
- [QUESTION] req.session.user undefined HOT 5
- Session always response the last login session when enable rolling with iisnode proxy HOT 1
- When Run frontend and backend in diff domain it not working HOT 2
- Undefined session object with apollo v4 express and express-session HOT 1
- Regenerated session is re-saved even if not modified since save HOT 1
- Allow for sessions to be shared between subdomains. HOT 1
- Invalid argument type express-session "1.17.3" and redis "4.6.7", HOT 1
- Request session destroy does not always resolve before returning HOT 1
- TypeError: Cannot read properties of undefined (reading 'reload') HOT 4
- [FEATURE REQUEST] Session Async Methods
- `SESSION.DESTROY()` DOES NOT DELETE SESSION. HOT 7
- A `destroy`ed session is still `touch`ed HOT 1
- cookie options won't get set HOT 13
- [Feature Request] Support of phasing out third-party cookies HOT 16
- req.sessionStore.all with typescript bug? HOT 7
- Don't `Set-Cookie` for static/public files? HOT 2
- Issue HOT 1
- Can't set partitioned cookie even though I updated all of the package HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from session.