question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

express-session creates new session over https

See original GitHub issue

I am using express-session with redis and as soon as I deploy the code to elastic beanstalk and use https, new session is created upon every request. If I use http then it works as expected. The problem is not with redis as I had the same issue before when I was using the memory to store the session

const app = express();
app.set('trust proxy', 1)

app.use(session({
  secret: uuidv4(),
  name: 'name_',
  resave: false,
  saveUninitialized: true,
  store: new redisStore({ client: redisClient, ttl: 86400 }),
  cookie: { secure: true }
}))

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
siyavash4812commented, May 21, 2020

I finally found out what was the problem 🎉 Cloudfront was not sending any cookies to my server. Such a silly mistake

1reaction
siyavash4812commented, May 21, 2020

Thank you for your message, the uuid is called once so I dont think that is the problem and I think If that was the issue, http would also be broken. I did some more digging and it seems like I have the exact same problem as renehauck (https://github.com/expressjs/session/issues/652). However, in my case I do receive “x-forwarded-proto”: “https”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node js express-session creating new session id every time I ...
SOLUTION: To overcome this for every request we are making from frontend(browser) we have to send that cookie to backend(server). Server will ...
Read more >
Express session middleware
Create a session middleware with the given options . ... both as HTTP and HTTPS, as once the cookie is set on HTTPS,...
Read more >
Session Management in Node.js using ExpressJS and ...
This tutorial will help the reader develop a session based authentication system and go over how to manage sessions using Express.js and ...
Read more >
Cookie and Session (II): How session works in express-session
Session is created in server when the client send a request to it for the first time. There are different ways to create...
Read more >
In Express Session Every Time new session id is generated ...
I am Using expression-session and express-mysql-session for storing in database but on every ajax returns new session id.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found