title: Cross domain cookie with two environments
body: <p>Currently I am stuck with a little problem which I would like to solve as cleanly as possible.</p>
  
  <p>I have two environments, a staging environment and a production environment. I'm using Ruby on Rails as a Framework.</p>
  
  <p>Each environment consists of three servers communicating with each other. For an authentication functionality a cookie is being shared among these three servers. Now the problem arises between staging environment and production environment since both environments share the same domain:</p>
  
  <pre><code>sub1-staging.example.com
  sub2-staging.example.com
  sub3-staging.example.com
  
  sub1.example.com
  sub2.example.com
  sub3.example.com
  </code></pre>
  
  <p>The cookie of the staging environment is also visible on the production environment. I guess that this is a common problem.</p>
  
  <p>Are there any good solutions to this except deleting the cookies after finishing working in one environment or renaming the cookie depending on the environment?</p>