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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:00:54+00:00 2026-06-13T08:00:54+00:00

I have a Backbone app that queries my Express server with a un/pw, authenticates,

  • 0

I have a Backbone app that queries my Express server with a un/pw, authenticates, then sends the account info (from MongoDB) along with the new sessionID back to the client. When i need more data, i attach the session id to the .fetch() options. However, Express creates a new session, even though my session was stored in Redis successfully.

Here is the middleware that checks if the client is trying to work with my api

var _restrictApi = function(req, res, next) {
  if (req.url.match(/api/)) {
    res.xhrAuthValid = req.param('sessionId') == req.sessionID;
    if (res.xhrAuthValid || (req.method=='GET' && req.url.match(/api\/account/))) {
      console.log('API access granted', req.url);
      console.dir(req.session);
      next();
    } else {
      console.log('API access BLOCKED', req.url);
      console.log(req.param('sessionId'), req.sessionID);
      console.dir(req.session);
      res.send(403, 'Forbidden');
    }
  } else {
    next();
  }
};

My Backbone app makes a few .fetch() calls upon loading. First, log-in, then grab events for the user. Here is the Express server console log:

API access granted /api/account?email=test%40gmail.com&password=somepw
{ cookie: 
   { path: '/',
     _expires: null,
     originalMaxAge: null,
     httpOnly: true } }
_checkAccount test@gmail.com
pw matches
{ cookie: 
   { path: '/',
     _expires: null,
     originalMaxAge: null,
     httpOnly: true },
  account: 
   { _id: 500471eb8bfff124ce984917,
     dtAdd: '2012-07-16T20:07:58.671Z',
     email: 'test@gmail.com',
     pwHash: '$2a$10$2KJXrZeAGW58Kp9JQDL9B.K2Fvu2oE3oqWKRl55o8MeXGHA/zCBE.',
     sessionId: 'iqYjOA7CeQHny9cm8zOWERjv' } }
API access BLOCKED /api/events?accountId=500471eb8bfff124ce984917&sessionId=iqYjOA7CeQHny9cm8zOWERjv
iqYjOA7CeQHny9cm8zOWERjv rsSXKtzXNNiq8x3+pUN9JXWF
{ cookie: 
   { path: '/',
     _expires: null,
     originalMaxAge: null,
     httpOnly: true } }
  • 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-13T08:00:55+00:00Added an answer on June 13, 2026 at 8:00 am

    Create a connect.sid by signing the sessionID:

    cookie = require('cookie-signature')
    res.send('connect.sid=s%3A'+cookie.sign(req.sessionID, req.secret))
    

    Store it in local storage and set the Cookie header for each AJAX request:

    r.setRequestHeader('Cookie', window.localStorage['connect.sid'])
    

    That works.

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

Sidebar

Related Questions

We have a backbone.js app that displays a number of forms to the user.
I have a backbone app with a view structure that looks like the following
I have a Rails 3.1 app that uses the codebrew/backbone-rails . In a .jst.ejs
I have a simple List-style Backbone app that I'm making with a Rails backend.
I'm using backbone for an app that I'm building. In this app, I have
I'm using mongodb, node.js and backbone.js to build an app that will serve as
I have a web app that I want to use Backbone.js for. I have
I am converting my backbone app so that it starts communicating with the server,
I have a backbonejs app that works something like this: [Backbone MODEL] <----> [Backbone
We have a Backbone.js app that supports file uploads using plupload. The uploads are

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.