Questions tagged [express-session]

Express' Straightforward Middleware for Efficient Sessions

Unable to establish a session on the Node server

I'm currently in the process of setting up a node server that includes login, logout, and authentication functionalities. However, I've encountered an issue with my code where after debugging, some debug information logs are being generated that I can't se ...

Transferring Session ID between Express.js and Socket.io while dealing with iframes from distinct origins

My Node application built with Express.js and Socket.io is facing an issue where they are not sharing the same session ID when running under iframe with different origins. When accessed directly or through iframes with the same origin, everything works fin ...

Error: Unauthorized access request occurs when the user does not exist in the database

Currently, I am working on implementing a basic login system using express sessions. However, I have encountered an issue where I receive an "Invalid status code" message when the user is not found in the database. I am aiming to set it up so that if the ...

Display or conceal the options to sign in and sign out

I am having issues with button visibility based on user authentication in my MySQL and EJS setup. connection.js const mysql = require('mysql'); const util = require('util'); require('dotenv').config(); const connection = mysql.createConnection({ host ...

I'm experiencing an issue where my express-session is being reset with every new request, leading me to question if this is related to the development environment I am using (REACT + EXPRESS)

UPDATE - I have ruled out a development environment issue as the same problem persists in production. Thank you for taking the time to look into this. I've searched through numerous questions and attempted various solutions with no success. To give you s ...

Utilizing express mysql authentication to connect to preexisting WordPress user accounts

Currently working on developing a login PWA using React and Node for an established WordPress site. Any suggestions on how to verify the password provided by the user against the encrypted WordPress password created when the account was initially set up? ...

"Encountering issues with express-session failing to store information

I am developing a basic MEAN application and I am interested in creating a custom user authentication system. My plan is to store the userId in the session upon login, and then verify the existence of the userId in the session on each page request (such as ...

What is the best way to create persistent cookies using node.js in conjunction with express-session?

I'm looking to implement persistent cookies in my app to avoid the need for users to log in every time they visit the website. The goal is to only require a login if they choose to log out. I'm curious if there's a way to set the maxAge of t ...

Cookies are not persisting in the browser even after successful login on a React Node.js application deployed on Render hosting platform

I recently completed a Full-stack MERN (React + Node.js + MongoDB) project by following a tutorial on YouTube. You can check out the tutorial here. The official GitHub repository for this project can be found at https://github.com/codinginflow/MERN-course ...

"EPERM: unable to rename file due to permission restrictions" error occurs when using Express session with session-file-store library

Currently, I am developing a node application that operates on the express web server using express-session and session-file-store for managing sessions. Since incorporating these components into my project, my debug console has been inundated with errors ...

Why is the function app.get('/') not triggering? The problem seems to be related to cookies and user authentication

Need help with app.get('/') not being called I am working on implementing cookies to allow multiple users to be logged in simultaneously. Currently, users can log in successfully. However, upon refreshing the page, all users get logged in as the ...

How can we start a new session upon signing up using cookie-session and passport.js?

Currently, I have set up a /register router specifically for signing users up. In order to keep things simple right now, I am utilizing cookie-session instead of express-session. However, I've hit a roadblock when it comes to authenticating a user du ...

Utilizing Ephemeral and MaxAge parameters in express-session for enhanced session management

I'm working on implementing the session management for an express-js application using the express-session package. Here are the specific requirements I need to meet: The cookie should be destroyed when the browser is closed. The cookie should expi ...

Tips for verifying the presence of an active session after closing the browser

Here is my situation: When a user logs into the app and then opens another browser window, they are already authenticated thanks to express-session, bypassing the login page. This pattern continues for subsequent browser windows. The issue I am facing no ...

Is it time to reconsider saving sessions in Node.js?

Here is the provided code snippet: app.get('/vklogin', function(request, response) { console.log('Authorizing via "Vk.com" social network'.green); var url_parts = url.parse(request.url, true); var query = url_parts.query; var data = querystring.stringify ...

Do you think it's feasible to configure cookies for express-session to never expire?

Is there a way to make cookies never expire for express-session? If not, what is the maximum maxAge allowed? I came across some outdated information on setting cookie expiration on SO (over 10 years old) and here on express, which mentions a maxAge of 1 y ...

Issue with Express-session: Cookie expiration not being reset with every request

I'm currently utilizing express-session for authentication in my web application. Unfortunately, I've encountered a persistent problem where the cookie expiration time isn't being reset with each request. Here's the code snippet that I'm working with: mai ...

What exactly does the 'cookie-parser' middleware do?

I have experience building back-end applications with express.js, utilizing both express-session and cookie-session. However, I recently came across the cookie-parser package on npm, which seems to be quite popular. This has sparked my curiosity, Can so ...

Revamping Cookie-based sessions in express.js

I am currently utilizing the cookie-session module for Express.js to manage sessions. My goal is to refresh sessions on each page load or ajax call, as is typically seen in similar setups. Unfortunately, the documentation lacks any information regarding ...

Once the session is configured to be stored in the database, there is a noticeable lag before it becomes officially registered. It involves utilizing technologies such as Node.js,

When I log in, I want to be redirected to /makeitem, which requires a session to open. It used to work perfectly before I started using connect-session-sequelize. The cookie gets stored in db.Sessions right away so that part works. But now, after submittin ...

Exploring techniques for retrieving Express.js session cookies on the server-side prior to sending a response

Utilizing Express-session, Connect-mongo, and PassportJS on a Node server, I have implemented the following validation function: expressApp.post('/login', function(req, res, next) { passport.authenticate('login', function(err, user ...

Every time I open my browser, my Node.js web app creates a fresh session

Whenever I close all browser windows and reopen the web app, a new session is initiated, forcing me to re-authenticate each time. To give you an idea, my web application framework is <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfema ...

Node.js: Deciding between res.render and res.redirect in express-session

On my website, I have a login page and a myservices page. Once a user logs in, they should be redirected to the myservices page where their username is displayed. In the login.js file, the following code is used: req.session.user = "abc"; res.redirect('/ ...

Troubleshooting problem with cookies in express-session

I've been working on an app with express.js and vue 3, incorporating session-based authentication. While everything functions perfectly locally, I've encountered issues when trying to deploy to production. Here's a snippet of the code where ...

Could it be that express-session is not compatible with express 4.13?

I have followed the setup instructions for express-session as outlined in the documentation, but it seems that my cookie is not being created. According to the documentation, simply setting the request.session value should automatically set the cookie. How ...

Error in returnTo behavior. The URL is being deleted just before making the post request

I have implemented express-session and included a middleware that assigns the value of req.session.returnTo to the originalUrl. router.post( '/login', passport.authenticate('local', { failureFlash: true, failureRedirect: &ap ...

Encountering login difficulties during initial login attempts may result in automatic logout upon page refresh within Angular+(Node/express).js framework

After attempting to log in for the first time, I noticed that the authentication process in AuthService sets the loggedInStatus to true. However, in AuthGuard, the loggedIn status is set to false, preventing navigation to the dashboard. Additionally, the c ...

accessing past sign-ins with passport.js and express-sessions

I need some assistance with displaying a user's login history on the front-end of my webpage. I am using Express and storing sessions in mongoStore as shown below: app.use(session({ secret: process.env.SECRET, key: process.env.KEY, resave: false, ...

The application successfully establishes a connection with the local MongoDB, but unfortunately, encounters session creation issues upon deployment to the Heroku server

This is my first time deploying an app, and I'm facing a particular issue. When hosting the app locally, I can use mongo (via Atlas) without any problems. Users are created on sign up, and they have a session. However, when I deploy the code to Heroku (us ...

I'm having trouble with my express sessions not persisting and instead a new session (or multiple sessions) being created for each request. What could be causing this

I am encountering an issue with my node.js express app where the sessions are not persisting and a new session is created for every request. If anyone can help me understand why this is happening, I would greatly appreciate it. Due to the size of the app, ...

Is it possible to implement React Native authentication by utilizing Express sessions?

I currently have a web application that utilizes React on the frontend and Express sessions on the backend for authentication and authorization. I'm interested in exploring if I can apply a similar approach to authenticate mobile users. In my web appl ...

Issue with Node.js: req.session data does not persist

Currently, I am working on integrating a login feature using express, nuxtjs, and express-session. The functionality works well without any issues until the page is refreshed. However, after refreshing the page, the session data is not retained. I have co ...

Ways to verify user authentication for navigating Vue routes

Working on a Single Page Application with Vue front-end, Express, and Parse (parse-platform) for back-end. After authenticating the user, I store their info in a session variable req.session.user = result; before sending it back to the client using res.sta ...

Is there a way to link the req.session.user from express-session to a chai-http request?

When it comes to my API, it relies on the express-session module for authentication. Each request is verified based on whether the req.session.user object exists within the request. The implementation can be seen in the snippet below: app.use(function(req ...

A guide to sharing session variables with express views

Struggling to access session variables in EJS views and encountering various challenges. To locally access req.session, I've implemented middleware as outlined in this guide on accessing Express.js req or session from Jade template. var express = re ...

Tips for handling multiple sessions in Express JS

I am currently working on a website that has two URLs ('/', '/admin') and I am facing session conflicts. Here is the code from my app.js: app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app. ...

Each time a post request is made, SessionID creates a distinct value

I'm facing a challenge in identifying the user on my application using sessionId instead of actual user account information. However, I've observed that the sessionId changes every time the user interacts with the page, as seen below. My objectiv ...

Tips on incorporating express-mysql-session in a TypeScript project

I'm experimenting with using express-session and express-mysql-session in a Typescript project. Here's the relevant snippet of my code: import * as express from "express"; import * as expressSession from "express-session"; import * as expressMyS ...

Leverage the power of express-session in your NextJS project

Currently, I am working on developing a login system using NextJS and MySQL. I am looking to implement sessions for user login, but I am unsure of how to integrate express-session with NextJS. Can anyone provide guidance on whether express-session can be ...

The persistence of req.session in express-session seems to be unreliable

I am facing an issue with my current code implementation. Here is the snippet: var express = require('express'); var cookieParser = require('cookie-parser'); var http = require('http') var app = express(); app.use(cookieParser()); var session = require('e ...

Utilizing cookie-session with Node.js Express for session management

After discovering that express-session is not suitable for production environments without switching to something like redisStorage, I opted for cookie-session. The documentation appeared a bit confusing. It states Other options are passed to cookies.g ...

Is express-session failing to create a cookie?

Currently, I'm going through Ben Awad's 13-hour Fullstack React GraphQL TypeScript Tutorial and I hit a roadblock while trying to set the login cookie around the 1 hour and 50-minute mark. I believe I successfully established a connection with r ...

Setting up "connect-redis" in a TypeScript environment is a straightforward process

Currently, I am diving into the Fullstack React GraphQL TypeScript Tutorial I encountered an issue while trying to connect Redis with express-session... import connectRedis from "connect-redis"; import session from "express-session"; ...

Are cookie-session and JWT tokens essentially the same thing in Express, or is there a difference between them?

When looking at the express documentation, you will come across a differentiation between express-session and cookie-session. The explanation provided is as follows: There are two main ways to store a user session with cookies: either on the server or on ...

Secure cookie session not being transmitted by Express on remote server using HTTPS

I am experiencing a challenge where Express is not including the Set-Cookie header when using express-session and setting the secure option to true. This issue arises specifically on a remote server with a valid certificate signed by Let's Encrypt. co ...

Encountered an issue with saving session using express-session

Utilizing Express-session within /api/login to store session data. I encountered an issue when trying to increment the count variable by one, as it always returned the number 1. Furthermore, the browser was not receiving the connect.sid value. Below is t ...

Issue with setting cookies on the client side when using NodeJS, VueJS, and express-session

I have been working on an app that already has its own infrastructure. My current task is to integrate a session-cookie mechanism, but I've been struggling to make the cookies set on the client side after spending a significant amount of time investigating ...

Conducting testing sessions for middleware in Express

I am struggling to test middleware functions in my Express application using supertest and nock. The issue arises from the fact that the routes I have configured are checked by a previous middleware function to ensure the existence of a session property on ...

The issue of "undefined is not a function" is arising when trying to use the session in NHibernate with a mongo store

In my MongoDB database, I have a collection named 'Sessions' within the 'SessionStore' to store session state. To manage sessions, I am using express-session. Below is the code snippet used to set up sessions: var session = requi ...

Is the express-session expiration object not the appropriate data type?

Occasionally, my nodejs program — which is built with the express v4.12.2 and express-session v1.13.0 packages — encounters a TypeError exception leading to a crash: /app/node_modules/express-session/node_modules/cookie/index.js:136 if (opt.expires) ...

What is the best way to adjust the domain attribute in express-session according to the source of the request?

Utilizing express session, I have configured the domain to be domain: 'mydomain.com' in order for the session cookie to function across subdomains such as api.mydomain.com and staging.mydomain.com. However, this setup hinders the Set-Cookie head ...