Questions tagged [express-session]

Simple session middleware for Express

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

937 questions
65
votes
3 answers

When to use saveUninitialized and resave in express-session

I am newbie with the MEAN stack. I read the express-session github doc but there are some options which are unclear to me. Those options are saveUninitialized and resave. Can anyone please explain with examples what are the advatanges of using…
user7104874
  • 981
  • 1
  • 11
  • 20
45
votes
5 answers

Get cookie with react

I need to know if my user is connected or not. For that I want to read the cookies that I set in the server side with express-session : app.use(session({ secret: 'crypted key', resave: false, saveUninitialized: true, cookie: {…
Ugo Nicolai
  • 529
  • 1
  • 6
  • 11
30
votes
0 answers

Why am I getting "Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute"?

In a Chrome warning it says "Specify SameSite=None and Secure if the cookie should be sent in cross-site requests. This enables third-party use." How do I do this correctly using express-session? app.use( cors({ credentials: true, origin:…
Squirrl
  • 3,870
  • 9
  • 41
  • 75
19
votes
2 answers

React App with Express Backend & express-session

I currently have a React App (via create-react-app) and an Express server for my API calls. They are both running separately and have been working fine until I ran into this problem: I'm also using express-session and passport for user…
drewpel
  • 405
  • 3
  • 14
18
votes
1 answer

req.session in express-session not persisting

I have the following code: var express = require('express'); var cookieParser = require('cookie-parser'); var http = require('http') var app = express(); app.use(cookieParser()); var session = require('express-session'); app.use(session({ …
RobKohr
  • 5,745
  • 7
  • 40
  • 58
18
votes
2 answers

socket.io authentication with sharing session data, how io.use() works

Inspired by How to share sessions with Socket.IO 1.x and Express 4.x? i implemented socket authentication in some "clean" way where is no need to use cookie-parser and to read cookies from headers, but few items remain unclear to me. Example use…
Srle
  • 9,554
  • 7
  • 30
  • 58
15
votes
1 answer

Express Session not persisting after CORS calls

TL;DR: Can't succeed persisting session across multiple APIs call performed between a Backbone App and Node.js Server with Express, Express-Session and Express-Cors. Looks like session is reinitialized/lost after every call. Long version:…
nakwa
  • 1,005
  • 1
  • 12
  • 24
14
votes
1 answer

Express JS/ Node JS : Browsers are not setting cookie when secure=true, sameSite: 'none'

it sets the cookie if I run the server locally, but when it is hosted online : If secure=false, sameSite: 'none' then I get the following error Cookie “connect.sid” will be soon rejected because it has the “sameSite” attribute set to “none” or an…
Prashan
  • 161
  • 1
  • 7
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
  • 2,779
  • 4
  • 29
  • 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
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
  • 9,554
  • 7
  • 30
  • 58
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
  • 703
  • 3
  • 13
  • 25
11
votes
1 answer

Express session MongoDB store: connect-mongo vs connect-mongodb-session

By now (10.7.2016) express-session's github-page suggests two mongodb session stores: connect-mongo | A MongoDB-based session store - Github (775 Stars) connect-mongodb-session | Lightweight MongoDB-based session store built and maintained by…
Rentrop
  • 18,602
  • 6
  • 64
  • 93
10
votes
1 answer

How to use @types/express-session?

when I write this: import { Request } from 'express-serve-static-core'; router.post((req: Request, res, next) => { req.session.user = user; } tsc gives me an error: 'Object is possibly 'undefined'. I know the original Request type does not…
slideshowp2
  • 38,463
  • 29
  • 127
  • 255
10
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,037
  • 4
  • 24
  • 45
1
2 3
62 63