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

  • Home
  • SEARCH
  • 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 8186671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:17:29+00:00 2026-06-07T02:17:29+00:00

im developing a small application with login and having an issue accessing session data.

  • 0

im developing a small application with login and having an issue accessing session data.

nb: using express 3.0, coffee-script and mongoose

So in my app I have the following:

app.locals.use (req,res) ->
  res.locals.session = req.session
  res.locals.title = config.title
  res.locals.href = config.href  

In my login.coffee I do the following:

ModelUser.findOne {email: email, password: password}, (err, results) ->
    if err then console.log err
    if results?
       req.session.user = results
       req.session.authenticated = true
       res.redirect '/'
    else
       req.session.error = 'bad login'
       res.redirect '/'

If I go to output #{session.user} in Jade, I get [bject,Object], but if I enter in “name” or “email” it returns blank. If I go into console and log the session object in the app.coffee, you can see the following:

if req.session? then console.log req.session.user

returns:

{ _id: '4f9b60ba7a7ab7e7f711920e',
  email: 'foobar@gmail.com',
  name: 'Demo User',
  password: '078d2bf82ee269cd9577588d212655c3a2162dc5b09e7c29c6a343926ee881a9' }

But if do console.log req.session.user.email it gives me a 500 error saying its not defined.. but I dont know why because you can see it is defined.

EDIT:

Solved; It was an async issue with the application continuing on before it got the user.
Had to send a callback to the find and use next()

if req.session.authenticated 
    require('./lib/getUser')(req.session.uid, (results) ->
      res.locals.user = results
      console.log res.locals
      done()
    )
  else
    done()
  • 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-07T02:17:31+00:00Added an answer on June 7, 2026 at 2:17 am

    There is an async issue with the application flow. The server is continuing before the results are returned, thus being undefined.

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

Sidebar

Related Questions

I'm developing a small application using Blend, basically what I have in my application
I'm thinking of developing a small application using IronPython, however I want to distribute
I have question I'm developing small application to desktop in win Forms. I'm using
I am developing a small application in Java. I am using Java2D Library for
I'm developing a small application but I'm having problem while deploying the application on
I'm developing a small web application using Microsoft Silverlight 3. I'm using Microsoft Expressin
I am new to nhibernate. I am developing a small c# application, using the
I'm developing a small application that reads data from a database and displys it
I am developing a small silverlight application (using siverlight 4 and c#). In my
I am developing a small application using Struts, Spring and hibernate3. But now I

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.