RockPaperScissors

LizardSpock

Sinatra Session Extension

| Comments

I have just started to use a sinatra extensions called Sinatra Session. The write up on the main site is pretty good and only include a short summary below.

gem install sinatra-session

In your app (classy style)

require 'sinatra/base'
require 'sinatra/session'

class MyApp < Sinatra::Base
  register Sinatra::Session

  # Use helpers as required
  get '/' do
    session_start!
    session[:foo] ||= 'bar'

    #now view helper, etc, can call session[:foo] to get value 'bar'
  end

end

Comments