Reputation: 19151
I have a Rails app on a subdomain - xyz.domain.com, and a PHP app on another subdomain - abc.domain.com
When a user is logged into the Rails app, I would like to give them a session so that I can log certain events about that user in the PHP app but in the same database of the Rails app. I would essentially just expose an API that requires authentication.
What is the best way to go about this? I am not storing the session in a database
UPDATE I should mention that the goal is to allow authenticated access from the PHP site to the database that has been only used by the Rails app thus far. If a user is logged into the Rails app, I want to be able to track any events that occur on the PHP site and associate them with the user.
Upvotes: 0
Views: 349
Reputation:
I will reply, not knowing a lot about Rails.
You can customize the cookie name in php.ini. Between the session name and the correct cookie domain you can create a cookie that will be shared by both applications.
A "session" in PHP terms just implies a cookie whose value points to some set of saved data in the session store. For example, if PHP (using the default config) sees a cookie PHPSESSID=2b00042f7481c7b056c4b410d28f33cf
, it will look for a session file like /tmp/sess_2b00042f7481c7b056c4b410d28f33cf
. The file just contains the output of serialize($_SESSION)
.
So, sharing the session will share this cookie value, but nothing else intrinsically. You will have to decide how to share other values, if PHP is to insert log records. Some options:
Upvotes: 2
Reputation: 2855
i think session is not possible. you can use database to store authentication if they can share same database between subdomain.
Upvotes: 0