Jan
Jan

Reputation: 41

TypeError: Cannot set property 'id' of undefined in express session(Storing session in redis)

Iam developing Angular4 login app. I want to store session in Redis. iam using Express session.

But I am getting the below error:

 req.session.id = userName;
                                               ^

TypeError: Cannot set property 'id' of undefined

Upvotes: 0

Views: 4663

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222582

You need to declare session first

req.session = {};
req.session.id = userName;

Upvotes: 1

Related Questions