Search code examples
sessionsinatrarack

Sinatra + Rack::Session::Pool + Moneta


I'm using server side session handling with Moneta in my Sinatra application.

The part of my config.ru looks like that:

require 'rack/session/moneta'

use Rack::Session::Moneta do
  use :Expires
  adapter :Memory
end

How long does is take for sessions to expire? I couldn't find documentation for it. I currently delete sessions with

get '/logout'
    session.destroy
end

But I believe that only destroys the session cookie on the client side. How can I find the sessions which are currently active?

There is a variable called @pool in Rack::Session. How can I access it from my Sinatra app?


Solution

  • You would set the expiration time when storing/accessing session keys by adding the expires: n option (set n to 0/false to have disable expiration). Here is the relevant entry in the Moneta README.