Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
console.log doesn't print all express session properties in node js

This code

router.post("/", (req, res) =>
{
    console.log(req.session)
    console.log(req.session.id)
})

prints

Session { cookie: { path: '/', _expires: null, originalMaxAge: null, httpOnly: true }, passport: { user: 'red' } }

and then

2sJgQxjBCbKgPiUN3pUdcDty_35GELeE

Is session.id stored inside session? Why it is not displayed after the first call to console.log?

Here is the setup:

app.use(bodyParser.urlencoded({ extended:true }))
var RedisStore = connectRedis(session)
app.use(session(
    {
        store: new RedisStore({ url: config.redisStore.url }),
        secret: config.redisStore.url,
        resave: false,
        saveUninitialized: false
    }))
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In Node.js, console.log only displays own enumerable properties of an object by using Object.keys().

The id property of a Session instance is not enumerable since it's defined as (enumerable: false by default):

Object.defineProperty(this, 'id', { value: req.sessionID });

Source

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!