Questions tagged [express-session]

Simple session middleware for Express

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

1209 questions
8
votes
1 answer

How Session Data is stored in NodeJS in server-side?

I am a beginner in NodeJS. I was working on a simple session-based user authorization to get a taste and it is working perfectly fine as there are plenty of examples around the internet which are easy to understand. I used express-session and the…
8
votes
1 answer

GraphQl and passport session: access req.user when querying GraphQl

I have a GraphQl server and a react frontend. I use passport and LocalStrategy to authenticate the user which works well, I can successfully login an existing user. I also want to use passport session to create a user session, so that I can access…
8
votes
3 answers

How to use express-mysql-session in Typescript projects?

I'm trying to use express-session and express-mysql-session within a Typescript project. Here's the relevant part of my code: import * as express from "express"; import * as expressSession from "express-session"; import * as expressMySqlSession from…
Timo Kunze
  • 135
  • 1
  • 6
7
votes
2 answers

Cookie not set with express-session in production

My app is divided between Client and Server. Client is a frontend side Nextjs app hosted on Now.sh, Server is its backend created with Express and hosted on Heroku, so the domains are client-app.now.sh and server-app.herokuapp.com…
The_Wolf
  • 175
  • 1
  • 4
  • 14
7
votes
1 answer

req.session.destroy and passport logout aren't destroying cookie on client side

I'm trying to destroy the cookie on the client side but can't seem to figure out how to. I've tried the few ways that passport and some answers on SO provided but I'm at a loss as to how to clear the actual cookie. My code so far…
user4747724
7
votes
2 answers

How to track req.session variable with node-inspector to understand how a session object gets removed from request.session

//Initializing session app.use(session({ secret: 'keyboard cat', resave: true, saveUninitialized: true //cookie: { secure: true } })); I was creating a shopping cart and came across a problem , I was setting cart object in session…
codefreaK
  • 3,584
  • 5
  • 34
  • 65
7
votes
1 answer

Session is not correctly obtained from a storage, using express-session and passportjs

I'm using passport, express-session and connect-pg-simple. The problem is that session is not correctly obtained from a storage, where it gets properly (i hope, but doubt) saved. My setup is the same, as in many tutorials, I've found…
AntonAL
  • 16,692
  • 21
  • 80
  • 114
7
votes
4 answers

NodeJS express session expire after page refresh

The session of my nodejs app is expiring every time I refresh the page, after login. It does work fine if I visit different pages but as soon as I refresh the page, the session ends. I've tried a couple of things but none of it seems to work. How…
aswheels media
  • 71
  • 1
  • 1
  • 3
7
votes
2 answers

Node js express-session creating new session id every time I refresh or access the page

I am facing the issue : on every request new sessionID is getting created. Can someone throw light at this ? Versions I am using: NODE VERSION: v6.10.3 NPM VERSION: 3.10.10 express@4.15.3 express-session@1.15.3 Also what is the default value…
Nitin Lodhe
  • 235
  • 1
  • 6
  • 14
7
votes
1 answer

Socket IO using express session - socket.request.res undefined

I am currently trying to implement session management using express 4.x and socket io 1.4, referencing this answer. The problem is that the second argument to the express session function is the res (response) object which is returning 'undefined'…
naughty boy
  • 2,089
  • 3
  • 18
  • 28
7
votes
1 answer

How to generate custom session id with express-session?

I am using Redis as session store and I would also like to create custom session id with express-session. So far I achieved was creating session with constant string like this: redis configuration var express = require('express'); var path =…
surenyonjan
  • 2,097
  • 3
  • 17
  • 26
7
votes
2 answers

Is it possible to get an express session by sessionID?

I have a NodeJS Express app that uses express-session. This works great, as long as session cookies are supported. Unfortunately it also needs to work with a PhoneGap app that does not support cookies of any kind. I am wondering: Is it possible to…
user1031947
  • 6,294
  • 16
  • 55
  • 88
6
votes
2 answers

TypeError: Cannot read properties of undefined (reading 'createClient')

so what I want to do is to create a session and store it in redis. I followed the API from this github repository https://github.com/tj/connect-redis. But I am getting this error in the word client: The expected type comes from property 'client'…
John
  • 125
  • 2
  • 7
6
votes
8 answers

Error: Cannot init client | mongo-connect express-session

I am getting error while trying to save session on mongodb. Here is my code.. const express = require("express"); const session = require("express-session"); const MongoStore = require("connect-mongo").default; const app = express(); let…
Irfan Habib
  • 148
  • 1
  • 1
  • 8
6
votes
1 answer

Node.js, Angular, express-session: Chrome 80 does not save session because of cookie policy (sameSite cookies)

I have a Node.js, Angular app. (Node.js server written in TypeScript). Node.js Server is running on an Amazon EC-2 instance, the Angular client is on another server. For the login session, I use express-session. I am not using cookies in the app, so…
1 2
3
80 81