title: Rails + Sinatra apps sharing sessions
body: <p>I haven't found a good answer to this yet. How can I get my Rails app and Sinatra app (mounted in my Rails app's config.ru) to share a session successfully? If I visit my Sinatra app first, then the Rails app, I get an error like <code>undefined method sweep for {}:Hash</code>, presumably because Rails uses a custom subclass of Hash for storing session info, and Rack::Session::Cookie doesn't. My code so far:</p>
  
  <p><strong>config.ru</strong></p>
  
  <pre><code>map "/" do
    run MyRailsApp::Application
  end
  
  map "/sinatra" do
    use Rack::Session::Cookie, 
        key: "_app_session",
        secret: "&lt;SECRET_KEY&gt;"
  
    run MySinatraApp
  end
  </code></pre>
  
  <p><strong>config/initializers/session_store.rb</strong></p>
  
  <pre><code>MyRailsApp::Application.config.session_store :cookie_store, key: '_app_session'
  </code></pre>
  
  <p><strong>config/initializers/secret_token.rb</strong></p>
  
  <pre><code>MyRailsApp::Application.config.secret_token = "&lt;SECRET_KEY&gt;" # same as config.ru
  </code></pre>
  
  <p>Anything I've missed?</p>