Questions tagged [express-session]

Simple session middleware for Express

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

1209 questions
14
votes
2 answers

What's the difference between saveUninitialized and resave?

The session middleware for Express provides several configurable options. resave: 'Forces the session to be saved back to the session store, even if the session was never modified during the request.' saveUninitialized: 'Forces a session that is…
Cannoliopsida
  • 3,044
  • 5
  • 36
  • 61
12
votes
3 answers

NodeJS redis connect session ID is regenerated when it should stay persisted

I tried to use the standard session persistance with Redis in NodeJS: var express = require('express'); var RedisStore = require('connect-redis')(express); var app = module.exports = express.createServer(); //…
Raph
  • 121
  • 1
  • 4
12
votes
4 answers

Namespace 'Express' has no exported member 'SessionData'

I'm trying to build a typeScript project but it has an error and I do not know where it comes from and nothing has changed since last time. node_modules/connect-mongo/src/types.d.ts:113:66 - error TS2694: Namespace 'Express' has no exported member…
Reza Razani
  • 170
  • 2
  • 8
12
votes
3 answers

node express, how to clear cookie after log out

Basically i'm doing redirect from a.example.com to www.example.com and i expect to be able to delete cookies on www.example.com (because cookie is created with .example.com as the cookie domain), but following code doesn't work. I know that this…
Srle
  • 10,366
  • 8
  • 34
  • 63
11
votes
8 answers

express-session deprecated req.secret; provide secret option app.js:27:9

I typed npm start to run my program but this is the comment that U received in the terminal: express-session deprecated req.secret; provide secret option app.js:27:9. I don't understand how this issue needs to be fixed. This is the code from…
Rhonda Mckenney
  • 129
  • 1
  • 1
  • 5
11
votes
1 answer

express-session secure: true

app.use(session({ secret: "testing credentials", store: sessionStore, resave: true, saveUninitialized: true, cookie : { httpOnly: true, //secure: true, maxAge : 60 * 60 * 1000 } })); I'm working on…
Pano
  • 2,099
  • 6
  • 16
  • 24
11
votes
3 answers

Local passport authorization on different ports

I have a node.js application running on port 5000, where I use passport.js as authorization. I authorize users from a post request, where I use a custom callback: this.router.post('/member/login', (req, res, next) => { …
DNRN
  • 2,397
  • 4
  • 30
  • 48
11
votes
4 answers

Error: Connection strategy not found MongoDB

here is a simple connection to use express session store, it keeps banging out this error even though the text is right from the book. I am pretty sure is has something to do with 'new MongoStore' object initialization. var express =…
Spencer Hire
  • 735
  • 3
  • 14
  • 32
10
votes
2 answers

How to extend express session timeout

I'm using express js 4 together with express-session and set maxAge to one hour. However if user continues accessing the website, the timeout should be extended otherwise the user will be logged out even he/she is still using it. app.use(session({ …
Anurat Chapanond
  • 2,837
  • 3
  • 18
  • 31
10
votes
2 answers

Session auto logout after inactivity

Is there a built in feature in express session, to enable auto logout after given time of inactivity ? I am using it as below, and want it to logout if session is inactive for half an hour. app.use(session({ key: 'sessid', secret: 'This is…
nishant pathak
  • 342
  • 1
  • 4
  • 17
10
votes
3 answers

NodeJS: "ENOENT" warning messages with sessions

I'm using node with the express-session and session-file-store packages. The session data is stored as files in the root directory, using the session-file-store package. However, now my logs are being clogged because the message…
terpak
  • 1,131
  • 3
  • 17
  • 35
9
votes
3 answers

Express-session is not setting cookies in browser

So I'm using express-session package to set cookie and session. It's also connected to my MongoDB store to store session. When user logs in, session gets stored in database just fine but there's no cookie in the browser. My app is running in…
9
votes
1 answer

Proper configuration for Node session storage with Redis Cloud and Heroku

It is unclear what are the correct configuration parameters to use are in the situation of using Redis Cloud and Heroku, and can't find a functioning example online. Here is my current code: const express = require('express') const session =…
9
votes
2 answers

Node.js, ws and express-session : how to get session object from ws.upgradeReq

I have an application built on express, express-session and ws ( for the websocket support). I have used this code to enable the session middleware: app.use(session({secret: 'mysecret',resave: true,saveUninitialized: true,cookie: {}})); And I can…
alexroat
  • 1,687
  • 3
  • 23
  • 34
8
votes
2 answers

Why express-session (SameSite atribute) isn't working on Chrome?

I am developing a web app with Express.js and React.js. I am using express-session but it is not working. This is how i am using it: app.use(session({ store: new MongoStore({ mongooseConnection: mongoose.connection, ttl: 365 * 24 * 60 *…
1
2
3
80 81