Sharing a session between Ruby and PHP

后端 未结 2 1395
死守一世寂寞
死守一世寂寞 2021-01-12 17:57

Is it possible to share a session between my PHP app on a subdomain and my Ruby apps on my other subdomains?

I don\'t really know where to take it from here. I know

2条回答
  •  自闭症患者
    2021-01-12 18:10

    This could be solved with apps sharing the same database and with a little help of cookies.

    • Session opened in php
      • Create a cookie with random string in it
      • Save the string in database with user credentials and timestamp
    • Session forwarded to rails
      • Check if the cookie exists
      • Search the string in cookie form the database
      • If match is found, then session is accepted and the same user credentials could be used

    It would be wise to store some kind of unique information of the workstation or the browser, so that stealing the session, with copying the cookie wont work.

提交回复
热议问题