title: Rack: Multiple session cookies for a single rack application
body: <p>How can one interact with multiple sessions cookies (for different path or domains) in a single rack application?</p>
  
  <p>For example, considering the following application using 3 locations:</p>
  
  <ul>
  <li>www.my-app.net => main app</li>
  <li>www.my-app.net/app_a => sub app A</li>
  <li>app_b.my_app.net/ => sub app B</li>
  </ul>
  
  <p>Should be able to interact with 3 sessions cookies:</p>
  
  <ul>
  <li>domain=www.my-app.net; path=/;</li>
  <li>domain=www.my-app.net; path=/app_a;</li>
  <li>domain=app_b.my-app.net/; path=/;</li>
  </ul>
  
  <p>Rack::Session::Cookie seemed to be a good choice, but as a middleware the session cookie has to be set in config.ru and seems to be limited to one session cookie per rack application.</p>
  
  <p>In this special case, the main rack application point is to easily add sub applications, so dividing the application in multiple rack application to use Rack::Session::Cookie is not a viable solution.</p>
  
  <p>The ideal would be a way to interact freely with multiple session cookies from inside the rack application code.</p>
  
  <p>For now, I am considering:</p>
  
  <ul>
  <li>writing a middleware that allow interaction with multiple session cookies</li>
  <li>use CGI::Cookie to implement a custom session cookie management inside the application</li>
  </ul>
  
  <p>But both are quite tedious so I was wondering if there was a simpler way to achieve this functionality.</p>
  
  <p>Thanks in advance for any advice or suggestion.</p>