views:

31

answers:

1

The site is currently written in PHP. I want to add a new component by doing it in Ruby on Rail and then installing Rails in a sub-folder.

If a user logs in the PHP portion of the website, can I customize the content for him/her in the Rails section without requiring a second login?

I'm relatively new to Ruby on Rails so that's why I'm asking all these noob questions.

+1  A: 

I guess you add some value to a cookie to authenticate the user.
Cookies are shared between applications. So you can authenticate your user in your rails application.

If you do, in php :

<?php $_COOKIE['foo'] = 'bar'; ?>

Then, in your rails controller, you can do :

method_that_checks_the_user cookies[:foo]
Damien MATHIEU
Be warned -- this is hackable since both the Rails app and the PHP app need to be able to decode / confirm `bar` in order to verify the user -- unless you take additional steps (using a shared database for your sessions and use the session key). Even then, it *may* not be entirely secure. (Someone like The Rook would be better equipped to answer that question).
Sean Vieira