views:

101

answers:

1

I'm running a Rails app on Heroku, and I'm trying to port over all inline Twitter requests (namely oauth authentication) to a Node.js app, because when Twitter is slow, since the Ruby server is blocking, the Twitter requests clog up my app. (My average request takes about 50ms, but my average Twitter Oauth request takes about 1500ms!)

The node.js app and the rails app can access the same database.

What I can't figure out, though, is how to initiate a session with node.js, and then use that session in the rails app. Right now I'm using the default Rails cookie session store.

I'd want it to work something like...

1) user arrives at landing page http://railsapp.com

2) user initiates log-in with http://nodeapp.com/login or http://nodeapplogin.railsapp.com

3) user does the twitter oauth dance with node.js

4) upon successful log in, user is redirected to http://railsapp.com/dashboard WITH an active rails session that can be used throughout the rails app

Any ideas/suggestions?

+1  A: 

You're going to want cookie based session key storage, set a global cookie domain to your toplevel 'railsapp.com', share your session store in a way both Node.js and Rails can access it.

I don't know the internals of Node.js session management, but I imagine it should be able to load a db-backed rails session store.

Winfield