title: Adding cookie session store back to Rails API app
body: <p>I have a Rails-API app. More or less "out of the box" but I want to add back cookie-based session store. Here is what I've done:</p>
  
  <p>app/controllers/application_controller.rb</p>
  
  <pre><code>+ include ::ActionController::Cookies
  </code></pre>
  
  <p>config/application.rb</p>
  
  <pre><code>+ config.middleware.insert_after ActiveRecord::QueryCache, ActionDispatch::Cookies
  + config.middleware.insert_after ActionDispatch::Cookies, ActionDispatch::Session::CookieStore
  </code></pre>
  
  <p>created config/initializers/secret_token.rb</p>
  
  <pre><code>+ Namespace::Application.config.secret_token = 'token'
  </code></pre>
  
  <p>created config/initializers/session_store.rb</p>
  
  <pre><code>+ Namespace::Application.config.session_store :cookie_store, :key =&gt; '_namespace_key'
  </code></pre>
  
  <p>When I inspect the session in a controller it results:</p>
  
  <pre><code>&lt;Rack::Session::Abstract::SessionHash:0x3fdadc5daa24 not yet loaded&gt;
  </code></pre>
  
  <p>However it does appear that data is being written to and used.</p>
  
  <p>But, in my browser the cookie itself is being named as '_session_id' instead of '_namespace_key'</p>
  
  <p>I thought I added back every piece required for cookie based session storage, but I appear to be missing something else. Any ideas?</p>