Sharing Sessions b/w 2 different apps?

Hi

Is there anyway we can share a login session between two apps one of which is developed in php and the other one in Ruby or Perl or Python?

Thanks

You can store your sessions in a database that both applications connect to and then keep a record of your active session in a cookie. You will of course have to validate the cookie data to make sure it is not spoofed by storing client data in your session table at the time of creation and then match it against the connecting client when you load up the session in a different app, etc.

APP #1

  • user connets
  • user logs in (create cookie and insert session record to database with client specific identifiers)
  • user does what ever they need to in App #1

APP #2

  • user comes to App #2 while they have a session cookie from App #1
  • App 2 recognizes the cookie and checks the session table in the db to see if their session is active and if their IP / browser matches the previous auth
  • if everthing checks out, consider the user’s session active
  • do what you need to do

Does that even remotely make sense?

Yes.

Thank you,

This is, incidently, one of the few remaining reasons to use database sessions instead of the $_SESSION superglobal.