Turn sessions on or off
[sinatra.git] / lib / sinatra / sessions.rb
blobce431b12e648f8a5069577d1e05bcf70b588089a
1 module Sinatra
2   module Session
3     class Cookie
4       def self.use=(v)
5         @@use = v unless Sinatra::Server.running  # keep is thread-safe!
6       end
7       
8       def initialize(app, options = {})
9         @app = if (@@use ||= :on) == :off
10           app
11         else
12           Rack::Session::Cookie.new(app)
13         end
14       end
15       
16       def call(env)
17         @app.call(env)
18       end
19     end
20   end
21 end