8
我有一個使用enable :sessions
構建的Sinatra webapp,在那裏我使用session[:mything]
訪問我的會話數據。Rack :: Session :: Pool Sinatra
我現在想要在服務器端存儲數據(即基於數據庫的會話),我不知道如何使用Rack::Session::Pool
,這似乎是我需要使用的東西。
如何將我的webapp轉換爲使用Pool?
我知道我需要添加行
use Rack::Session::Pool
下一步怎麼走? - 提前致謝!
編輯:這是使用基於cookie的會話的例子:
require 'rubygems'
require 'sinatra'
enable :sessions
get '/' do
session.merge!(params)
session.inspect
end
訪問/?hi=there
然後訪問/
,你仍然會看到{'hi'=>'there'}
,因爲它已經存儲在cookie中。
Rack :: Session :: Cookie提供簡單的基於cookie的會話管理。 – Liber 2014-05-05 02:09:56
@Liber OP需要一個不同類型的會話,而不是'Rack :: Session :: Cookie'提供的會話,因此Konstantin Hasse的回答是。 – 2015-10-07 15:30:06