1

I have two web apps running. One is a rails app which is the beef of the application, and the other is a wordpress app(for an online store).

My challenge is sharing login data/session data between the two apps. So If I log into the rails app, and then click the shopping tab, how do I transfer the user session over to the wordpress site?

Also Vice versa. If I am shopping on the wordpress site, and want to login to purchase items, how can I login via the rails app?

I believe there are single sign on plugins that can achieve this, but I have not found anything that is to specific on how to achieve this. For some reason wordpress is awfully terrible to develop around :(.

7
  • What about using OpenID/oAuth? I'm sure that'd be far less stressful to implement than having to join up he dots and potentially create an insecure hole! Commented Sep 3, 2015 at 21:13
  • @ScottMcGready I have thought about that. I have never used openid before, but am assuming that it is a unique id for users shared between both apps? Commented Sep 3, 2015 at 21:16
  • I have a proposition where the user click a special link in the rails application and this action connect him in WordPress. can this help you ? Commented Sep 3, 2015 at 21:18
  • @Seal More or less. I'd certainly try and keep away from any custom solutions as its bound to cause issues security wise. Commented Sep 3, 2015 at 21:20
  • FYI Wordpress sessions are stateless Commented Sep 3, 2015 at 21:23

1 Answer 1

2

Are the 2 applications running on the same host? Same domain? Sharing database?

Sounds like your best option is some sort of authentication service, like one of the many OAuth authenticator services (Facebook, Twitter, etc.), or writing your own OAuth service.

Alternatively, if the 2 applications are small-scale and running on the same machine, it might be possible to modify the session handler for either the rails app or WordPress to use the other's session data. I suspect WordPress would be the easier of the two to modify, but I have bias toward PHP

Did a quick search and found this article about modifying Rails cookie sessions to use with PHP.

https://www.coffeepowered.net/2011/08/24/rails-cookie-sessions-and-php/

I also found this article which might be exactly what you're looking for? http://code.tutsplus.com/tutorials/build-a-custom-api-to-connect-wordpress-with-ruby-on-rails--cms-21189

Unfortunately, I have never attempted this from either direction. But I am very familiar with WordPress, and believe it could be made to corporate with Rails sessions, given enough blood, sweat and tears.

Sign up to request clarification or add additional context in comments.

3 Comments

They are not sharing a database, and are not running on the same domain. I like the api feature but this is supposed to be quick and dirty. I had the thought of creating an oauth server on the wordpress site, using devise and oauth ont he rails app to authenticate through wordpress, and redirect back into the rails app. Then they could logon to the wordpress site and rails app.
@seal how did you end up ?
I think I ended up using an oauth library to share data between the two

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.