# How to integrate a PHP app with RoR app?

**URL:** <https://www.ruby-forum.com/t/how-to-integrate-a-php-app-with-ror-app/89326>\
**Category:** Rails\
**Created:** [March 19, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/how-to-integrate-a-php-app-with-ror-app/89326 "2007-03-19T17:06:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wynners33](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/82dd89/32.png) [@wynners33](https://www.ruby-forum.com/u/wynners33)\
**Post date:** [March 19, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/how-to-integrate-a-php-app-with-ror-app/89326/1 "2007-03-19T17:06:19Z")

</div>

I have developed a RoR application and would like add on a feature.  
Found a opensource solution (although developed in PHP). I wonder how I  
can integrate - they can share the same DB (MySQL) but how about session  
variables?

Is there a way the php application and my rails app can share/exchange  
the session variables (e.g. user\_id, company\_id)?

Thanks!

---

<div class="post-metadata">

**Author:** ![wynners33](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/82dd89/32.png) [@wynners33](https://www.ruby-forum.com/u/wynners33)\
**Post date:** [March 19, 2007, 5:33pm UTC](https://www.ruby-forum.com/t/how-to-integrate-a-php-app-with-ror-app/89326/2 "2007-03-19T17:33:25Z")

</div>

I suppose there would be a way to implement a “single sign-on” system  
for your RoR and PHP applications.

As far as sharing session variables, that would likely require some  
sort of service in each application to exchange that data.

It’s my understanding that Rail is going to store Ruby objects in  
session data. You could write some sort of serializer/deserializer  
for reading the Ruby objects out of the sessions table for your Rails  
application, and vice-versa for your PHP session data, but that  
doesn’t sound like much fun and could be risky.

I would think that creating a web service (RESTful service might be  
good) to exchange session data between the apps is more feasible. But  
problem one is to implement “single sign-on” so your users will have a  
nice experience moving between the two applications.

On Mar 19, 12:06 pm, Gordon Lo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![wynners33](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/82dd89/32.png) [@wynners33](https://www.ruby-forum.com/u/wynners33)\
**Post date:** [March 19, 2007, 6:39pm UTC](https://www.ruby-forum.com/t/how-to-integrate-a-php-app-with-ror-app/89326/3 "2007-03-19T18:39:36Z")

</div>

Robert W. wrote:

> doesn’t sound like much fun and could be risky.
> 
> > can integrate - they can share the same DB (MySQL) but how about session
> 
> >

Also, you can do login from rails and proxy login info to PHP app.  
Check this two articles:  
[http://wiki.rubyonrails.org/rails/pages/HowtosDoSingleSignOnWithPHPbb](http://wiki.rubyonrails.org/rails/pages/HowtosDoSingleSignOnWithPHPbb)  
[http://wiki.rubyonrails.com/rails/pages/ExampleCookieJarHelper](http://wiki.rubyonrails.com/rails/pages/ExampleCookieJarHelper)

best,  
Bojan

–  
Bojan M.  
 → Ruby on Rails and Web D. Blog : [http://source.mihelac.org](http://source.mihelac.org)
