Questions tagged [express-session]

Simple session middleware for Express

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

1209 questions
95
votes
3 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, …
Squirrl
  • 4,909
  • 9
  • 47
  • 85
95
votes
6 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
  • 1,321
  • 2
  • 15
  • 21
84
votes
8 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: {…
Jackal
  • 1,041
  • 1
  • 10
  • 13
22
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
  • 465
  • 1
  • 3
  • 16
22
votes
6 answers

TypeScript: Extend Express.Session interface with own class

I'm working on a Typescript project with npm packages. I want to add a property to the Express.Session interface. example Class: class User { name: string; email: string; password: string; } export = User; New d.ts file for the…
Mr. Smith
  • 559
  • 1
  • 5
  • 17
21
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
  • 6,611
  • 7
  • 48
  • 69
20
votes
5 answers

Node.js server restart drops the sessions

I'm having fully functional user signup / authentication system using Express and Connect middleware. app.use(express.session({store: require('connect').session.MemoryStore( {reapInterval: 60000 * 10} ) })) The only problem is that sessions drop…
user80805
  • 6,088
  • 5
  • 28
  • 31
20
votes
8 answers

Express-session Secure Cookies not working

When not using secure cookie true setting, my app user login works fine. When I enable secure cookies, the login appears to go through fine, but it seems the cookie is not saved and the user is not logged in. In other words, this works: app =…
Justin Lok
  • 1,214
  • 2
  • 16
  • 35
18
votes
2 answers

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
  • 311
  • 2
  • 8
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
  • 10,366
  • 8
  • 34
  • 63
17
votes
2 answers

Cross-Domain Session Cookie (Express API on Heroku + React App on Netlify)

I have a React App making calls to an API in node.js/Express. Frontend is deployed in Netlify (https), Backend deployed on Heroku (https). My problem: Everything working in dev environment (localhost) In production (Netlify/Heroku), the api calls…
ludovico
  • 2,103
  • 1
  • 13
  • 32
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,157
  • 1
  • 13
  • 25
15
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
  • 20,979
  • 10
  • 72
  • 100
14
votes
5 answers

using apollo, cookie in response header but not being set

I'm developing a user login/register feature as part of a larger project and am working on localhost (apollo server and react apollo front-end). I'm using express-session for my sessions. When submitting my login I can see the response header has…
Michael Ross
  • 139
  • 1
  • 4
14
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…
Lin Du
  • 88,126
  • 95
  • 281
  • 483
1
2 3
80 81