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 7787501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:41:35+00:00 2026-06-01T20:41:35+00:00

I am building a restful api for my mongo database and I am trying

  • 0

I am building a restful api for my mongo database and I am trying to reload a users session based on the SID sent via the api call.
I have my server serving up sessions fine, but I can’t for the life of me figure out how to reload a session into req.session through connect-mongo and have it saved again (based on original sid) once the request is sent out.

Anything I saved to the req.session gets put into a completely new session, and doesn’t write to my previous session data.

I have no trouble writing something to save my session data pulled from the database but i figured there was a way to have to have it automactially handled by expressjs or connect-mongo.

  • 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-01T20:41:37+00:00Added an answer on June 1, 2026 at 8:41 pm

    I ended up solving my issue, though I think a lot of my headaches related to my poor understanding on how sessions should be handled. Although its not what i ultimately wanted, it ended up giving me essentially the same result.

    Looking over Patrick’s code got me thinking that is was probably some sort of scoping/binding issue. With a couple of tweaks I was finally able to access the connect-mongo prototyped functions by creating my mongoStore Obj outside of the express session then passing that obj into express.session.

    MongoStore = require('connect-mongo')
    var mongoSession = new MongoStore(conf.db);
    
    //Configure Session Db
    var conf = {
      db: {
        db: 'sessions',
        host: '127.0.0.1',
      },
      secret: 'kittens'
    };
    
    app.configure(function(){
      app.set('views', __dirname + '/views');
      app.set('view engine', 'jade');      
      app.use(express.bodyParser());
      app.use(express.methodOverride());
      app.use(express.cookieParser());
      app.use(express.session({
        secret: conf.secret,
        maxAge: new Date(Date.now() + 3600000),
        store: mongoSession
      }));
      app.use(allowCrossDomain);
      app.use(require('stylus').middleware({ src: __dirname + '/public' }));
      app.use(app.router);
      app.use(express.static(__dirname + '/public'));
    
    
    });
    

    Now i was able to easily get/set previous sessions through the mongostore obj. I know there are probably other ways to go about doing the same thing, (ie access mongodb directly) though I wanted to see what was possible simply with the mongostore obj itself.

    Also thanks for the thoughts on this Patrick, definitely helped me think in the right direction.

    Hope this helps someone!

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

Sidebar

Related Questions

I'm building Pylons-based web application with RESTful API, which currently lacks any authentication. So
When building a RESTful / hypermedia API with JSON resources, it seems I have
While building a RESTful API of my web service I'm trying to give clients
I am building an RESTful API for an application I am working on and
I'm building a RESTful app on Django and Tasty Pie. I have a problem
I'm building a RESTful API and want to provide developers with the option to
We are building a restful api using Spring MVC and freemarker as the templating
I'm building a RESTful web api with asp.net mvc, which returns pure json data.
Does anyone have any links for building RESTful web services with the ASP.NET Web
I'm building a website where users can sell products. I'm beginning with a RESTful

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.