Questions tagged [express-session]

Simple session middleware for Express

The express-session module is a simple session middleware for Express.

1209 questions
4
votes
2 answers

Why use cookie-session in addition to passport.js?

My understanding of passport.js so far is that passport.js serializes the user object and sends an ID every time to the client. I am just starting with it so sorry if it's a silly question: Instead of express-session, I am using cookie-session as I…
4
votes
2 answers

How to get session cookies from express-session in React

My node.js server is using express-session for authentication. const express = require('express') const session = require('express-session') const app = express() app.use(function (req, res, next) { res.header("Access-Control-Allow-Origin",…
4
votes
1 answer

Express-session not deleting previous sessions

I am currently working on a new project and I use sessions with the express-session library. Here is the code where I set up the session: const IN_PROD = process.env.MODE==='production' app.use(session({ name: 'sid', secret: 'asecret', …
blouuuu
  • 454
  • 1
  • 4
  • 16
4
votes
1 answer

Storing Data With Express-Session

Say you want a user to enter their email through input, and want to capture that email and persist it over multiple web-pages. Is it bad practice to store the email in the session object in express-session? Something like: req.session.email =…
kt-workflow
  • 359
  • 1
  • 3
  • 14
4
votes
0 answers

How to handle SameSite attribute in Express with incompatible clients?

Chrome is changing the default value of SameSite cookie attribute from None to Lax as of its version 80. My site is embedded to another site using an iframe and the login session of my site is handled by express-session. For new browsers the…
Samuli Asmala
  • 1,755
  • 18
  • 24
4
votes
0 answers

Connect-pg-simple not saving session to database

I am trying to implement simple authentication with Node, Express, Express-Session and Passport.js. As a storage middleware I'm using connect-pg-simple as I am using pg-promise in my project. I managed to configure passport to work with my routers…
Fiffe
  • 1,196
  • 2
  • 13
  • 23
4
votes
1 answer

set up mssql-session-store in node.js

I'm trying to use mssql-session-store as nodejs (express) store for session: https://www.npmjs.com/package/mssql-session-store This is how it should be configured(from npm page): app.use(session({ secret: 'keyboard cat', resave:…
Guy E
  • 1,775
  • 2
  • 27
  • 55
4
votes
3 answers

Simple Node/Express app not recognizing Session store

I have an extremely small express app to illustrate a problem I'm having. I'm using connect-redis as a session store on my express app. I'm having a problem simply connecting to it though. Simply printing out req.session.store results in undefined…
qarthandso
  • 2,100
  • 2
  • 24
  • 40
4
votes
1 answer

session not persisting when using secure cookie in NodeJS with express-session

I'm using NodeJS + express + express-session to persist a userID from anywhere in the application. On the first route, my session is defined userProfileRoutes.route('/authentication').post((req, res) => { req.session.userID = 10; //example …
user10623427
4
votes
1 answer

(Next.js, Express session) New session for every request made inside getInitialProps

I am trying to make Express session work with Next.js, and have successfully done so on the client side, but I am having trouble with API calls made from inside getInitialProps. Note: I am using isomorphic-unfetch to make API calls. My Next.js…
Robert
  • 171
  • 1
  • 8
4
votes
0 answers

Node express session not persisting in IPhone IOS

I have an application using Angular and Node (Nest JS) , in the server side i'm using express-session. In my middleware i'm adding the logged in user to the session: req.session.user = user; When the user tries to login using an Iphone he is not…
Shahar Shmaram
  • 233
  • 1
  • 4
  • 10
4
votes
2 answers

Passport.JS: Error: Failed to deserialize user out of session

I'm using Passport.JS with express-session and a MySQL database to handle user authentication. Everything was working fine until I removed all the sessions from database 'sessions' and all the users from database 'users'. Ever since then, I keep…
Elias
  • 123
  • 1
  • 1
  • 9
4
votes
2 answers

How To Access Session Variables From Seperate Route Files

I am currently using express and express-session to save information. If I save a session variable like this in file 'routes/login.js' req.session.user = "User1" How do I then access that same variable from 'routes/index.js' because currently if I…
Undying
  • 141
  • 3
  • 14
4
votes
1 answer

What is a secure session secret?

I am using express-session and I need to create a session secret. I have read that the secret is used for hashing. How long and what characters should this secret have? I was thinking about a random alphanumerical string like this:…
Luud van Keulen
  • 1,204
  • 12
  • 38
4
votes
2 answers

Retrieve sessions list from sessionStore and destroy user previous sessions NodeJS

I need to retrieve a list sessions from sessionStore(MongoStore) and delete previous login session. I am using express-session to store sessions in DB. var userId = req.query.userid; if (!userId) return res.status(400).send({ message:…
Zaid Iqbal
  • 1,662
  • 5
  • 25
  • 45