title: Rack::Session::Pool with Sinatra
body: <p>I have a Sinatra webapp I've built using <code>enable :sessions</code> where I access my session data with <code>session[:mything]</code>.</p>
  
  <p>I now want to store data on the server side (ie. with database based sessions) and I can't figure out how to use <code>Rack::Session::Pool</code>, which appears to be the thing I need to use.</p>
  
  <p>How do I go about converting my webapp for use with Pool?</p>
  
  <p>I know I need to add the line</p>
  
  <pre><code>use Rack::Session::Pool
  </code></pre>
  
  <p>what comes next? — thanks in advance!</p>
  
  <p><strong>EDIT</strong>: Here's an example using cookie-based sessions:</p>
  
  <pre><code>require 'rubygems'
  require 'sinatra'
  
  enable :sessions
  
  get '/' do
    session.merge!(params)
    session.inspect
  end
  </code></pre>
  
  <p>Visit <code>/?hi=there</code> then visit <code>/</code> and you'll still see <code>{'hi'=&gt;'there'}</code>, as it's been stored in a cookie.</p>