Search code examples
ruby-on-railssessioncookiessession-cookies

How to handle cookies across domains in development


I developed two rails apps, they will each go on site.com and something.site.com respectively. In development mode they are run on localhost:3000 and localhost:4000, you must be logged into site.com to access something.site.com.

I have the cookies set up to handle domains from :all, and the tests all pass in relation to creating and destroying sessions. How ever I am unfamiliar how to test the cookies with out actually deploying the apps to production. I don't have staging servers, their small basic apps and I don't want them public. Is their any ways, on my mac, I can test (by launching both apps) the domain specific cookies?


Solution

  • You can edit your hosts file located at /etc/hosts to point 127.0.0.1 to local.site.com and then access your rails apps at local.site.com:3000 and local.site.com:4000

    127.0.0.1 localhost local.site.com