I will try to explain as best I can my problem, because it is a lot of time that I am trying to solve it without success. I hope someone can really help me, however banal it may seem. So...
I have two RoR 3 applications:
- APP1: www.app1.example.com - APP2: www.app2.example.com
Notice (if it helps): I do not use www.example.com as a developed RoR application, for now. At the moment it is only a "nil" project, that is a RoR basic application simply generated through the command 'rails new example' in the Terminal.
In APP1 I have a 'APP1/controllers/user_authentications_controller.rb' with the following code to set user's cookies:
def create ... cookies.signed[:current_user_id] = { :value => [user.id, user.make_user_id_salt(user.id)], :expires => 15.days.from_now, :domain => ".example.com" } ... end
that means (I know) I set cookies accessible from all 'www.subdomain.example.com'. In fact, normally, I can access the value of the cookie with the code 'cookies[:current_user_id]' both from APP1 and APP2.
The problem happens when I try to access the value of the cookie by making a request from APP1 to APP2 and vice versa. For example, using in APP2 the code
Net::HTTP.get( URI.parse( www.app1.example.com/users ) )
and having in ''APP1/controllers/users_controller.rb'' the code
def index @check_var = cookies[:current_user_id] end
the debug of the @check_var in the ''APP1/views/users/index.html.rb'' shows me a blank value. For this reason I can not even use the conditional constructs and similar!
This is only an example, but it happens also when I use the REST approach with API, and I think also in other cases when I make an external request to APPs. It seems that RoR does not follow cookies.
So the question is: is it possible to get/share cookie or session information between more RoR applications?
I use a Mac with OS "Snow Leopard" v10.6.5, Apache2 and Phusion Passenger.