views:

116

answers:

1

I have a Sinatra webapp I've built using enable :sessions where I access my session data with session[:mything].

I now want to store data on the server side (ie. with database based sessions) and I can't figure out how to use Rack::Session::Pool, which appears to be the thing I need to use.

How do I o about converting my webapp for use with Pool?

I know I need to add the line

use Rack::Session::Pool

what comes next? — thanks in advance!

EDIT: Here's an example using cookie-based sessions:

require 'rubygems'
require 'sinatra'

enable :sessions

get '/' do
  session.merge!(params)
  session.inspect
end

Visit /?hi=there then visit / and you'll still see {'hi'=>'there'}, as it's been stored in a cookie.

+1  A: 

Simply replace the line enable :sessions with use Rack::Session::Pool. All enable :session does is adding Rack::Session::Cookie to the stack (which you want to avoid). The session helper will still work.

Konstantin Haase