express-session

express-session, connect-redis and einaros/ws

怎甘沉沦 提交于 2019-12-11 07:14:28
问题 I seem to be having some trouble getting Express, express-session, connect-redis and websockets/ws to play together nicely. This most likely has to do with my as yet limited understanding of these modules and coding in general. Most of the code here is taken from the respective examples in the repositories as well as other sources trying to accomplish something similar. So what we have here is a websocket-enabled app trying to immediately initiate a websocket connection to the server-side app

Cookie share with subdomain nodejs httponly cookie

情到浓时终转凉″ 提交于 2019-12-11 06:07:34
问题 I am using express-session module for maintain session. i have two app. i want to share cookies with this apps, parent app run in example.com , and child app run in child.example.com. i set httponly cookie using express-session it sets in the child app.i can verified that cookie in resource tab in chrome debugger. Network tab: When the first call to sub-domain: it load like "http://www.child.example.com" cookie set in the request. while the url is redirect to server IP . cookie not available

Calling express-session backed by connect-redis inside websockets/ws

百般思念 提交于 2019-12-11 05:48:23
问题 Okay so here goes. I am trying to to use express-session backed by connect-redis together with websockets/ws . The vast majority of example code I have seen usually includes the use of Express to serve the client a websocket script of some type and then configuring the server app to use the express-session middleware to work with session data...with websockets further down the process chain. My client side app on the other hand immediately initiates an Opening Handshake/Upgrade request, which

Express-Session is undefined

江枫思渺然 提交于 2019-12-11 05:43:17
问题 I am new to node.js and angular4 and am working on an application which required user authentication. I want to save the user role in a session in node.js and want to access that session in multiple routes. However, I am unable to get the role in other routes. I have checked many answers regarding the same but none have worked for me so far. Scenario: I have implemented Express-Session in app.js const session = require('express-session'); const cookieParser = require('cookie-parser') const

Renewing Cookie-session for express.js

倾然丶 夕夏残阳落幕 提交于 2019-12-11 01:07:17
问题 I'm using the cookie-session module for Expresss.js to deal with sessions. I would like the sessions to be renewed on every page load (or ajax call). That's how they usually work anywhere. The documentation doesn't say a word about it. I've tried doing this, but without success: app.use(function(req,res,next ){ req.sessionOptions.maxAge = 20*1000; return next(); }); 回答1: I suspect that you are not sending the response cookie to the client. I solved the same problem (using express and cookie

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

狂风中的少年 提交于 2019-12-10 23:31:01
问题 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 console.log(req.session) } The result of the console.log is: Session { cookie: { path: '/', _expires: null, originalMaxAge: null, httpOnly: true, secure: true }, userID: 10 } // this is the right value But then, from a different route, I can't see the value

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

大兔子大兔子 提交于 2019-12-10 13:56:51
问题 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 around. server.js: import express from 'express'; import next from 'next'; import bodyParser from 'body-parser'; import session from 'express-session'; import connectPgSimple from 'connect-pg-simple'; const sessionStorage = connectPgSimple(session); import

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

风格不统一 提交于 2019-12-10 13:36:23
问题 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' in my route. Is this question outdated or am I doing something wrong? var http = require('http'); var session = require('express-session')( { saveUninitialized : false, resave:false, secret:'secretstuff', cookie : { path : '/' } } ); var express =

How to run multiple express/Nodejs application in localhost?

血红的双手。 提交于 2019-12-10 11:44:30
问题 I am running my client(frondend) app express app in a port 3000 and another admin express app in 8080. But when I am navigating any pages or refreshing any page in client express app, the session in admin app is lost and redirecting to login. I am using Express-session npm for admin and frond end is just like a cms frondend, ie no sessions or anything complex. Can any body tell me why is this happening? 回答1: Cookies for an app running on port 3000 are also sent to an app running on port 8080

express-session: Rolling session expiry configuration

谁说胖子不能爱 提交于 2019-12-07 16:39:36
问题 So I'm using express-session with a mongo store like so: app.use(session({ secret: 'some secret here', saveUninitialized: false, resave: false, store: new MongoStore({ url: 'http://someurlhere' }) })); I have some login middleware, which after a successful login I want to then set the session cookie expiry time. So I am testing with a 10 second expiry time right now using req.session.cookie.expires = new Date(Date.now() + 10000); I want the session expiry to reset for each subsequent request.