我有一个 Sinatra Web 应用enable :sessions
程序,我使用session[:mything]
.
我现在想在服务器端存储数据(即使用基于数据库的会话),但我不知道如何使用Rack::Session::Pool
,这似乎是我需要使用的东西。
如何将我的 web 应用程序转换为与 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 中。