How can one interact with multiple sessions cookies (for different path or domains) in a single rack application?
For example, considering the following application using 3 locations:
- www.my-app.net => main app
- www.my-app.net/app_a => sub app A
- app_b.my_app.net/ => sub app B
Should be able to interact with 3 sessions cookies:
- domain=www.my-app.net; path=/;
- domain=www.my-app.net; path=/app_a;
- domain=app_b.my-app.net/; path=/;
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.
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.
The ideal would be a way to interact freely with multiple session cookies from inside the rack application code.
For now, I am considering:
- writing a middleware that allow interaction with multiple session cookies
- use CGI::Cookie to implement a custom session cookie management inside the application
But both are quite tedious so I was wondering if there was a simpler way to achieve this functionality.
Thanks in advance for any advice or suggestion.