Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9033615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:16:42+00:00 2026-06-16T08:16:42+00:00

Possible Duplicate: ‘session’ is undefined when using express / redis for session store var

  • 0

Possible Duplicate:
‘session’ is undefined when using express / redis for session store

var express = require('express');
var app = express();
var RedisStore = require('connect-redis')(express);
var session = require('redis-session')({

  debug: true,
  ttl: 90000000,
  connection: {port: '7170', host: '127.0.0.1'}    

});

app.configure(function(){

   app.use(express.bodyParser());
   app.set('views',__dirname + '/views');
   app.set('view engine', 'ejs');
   app.use(express.static(__dirname + '/public'));
   app.use(express.session({ secret: 'p!550ff', store: new RedisStore }));
   app.use(express.cookieParser());
   app.use(app.router);

});

With this configuration, any time I call req.session, nodemon tells me that it’s undefined. express.cookieParser() and express.session are well declared, I guess. Any solution…?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:16:43+00:00Added an answer on June 16, 2026 at 8:16 am

    The cookieParser middleware needs to come before the session middleware so swap the order like this:

       app.use(express.cookieParser());
       app.use(express.session({ secret: 'p!550ff', store: new RedisStore }));
    

    See the Connect docs on this here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Session variable is lost on RedirectToAction in IE I'm using MVC3 and
Possible Duplicate: What do I need to store in the php session when user
Possible Duplicate: How's the current state of Facebook's session and access_token? I am using
Possible Duplicate: PHP Storing Current Session IDs in Database using Cookies I want to
Possible Duplicate: Can't pass mysqli connection in session in php I'm trying to store
Possible Duplicate: PHP Session Fixation / Hijacking I've been using $_SESSION superglobal a lot
Possible Duplicate: Cache v.s Session I am using some code that uses HttpRuntime.Cache to
Possible Duplicate: Where are $_SESSION variables stored? I'm using this to store some data
Possible Duplicate: Firefox session cookies I'm creating a website in which users are allowed
Possible Duplicate: Where are $_SESSION variables stored? When ever we working with session, we

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.