[英]Rack::Session::Pool with Sinatra
我有一個使用enable :sessions
構建的Sinatra webapp enable :sessions
,我使用session[:mything]
訪問會話數據。
我現在想要在服務器端存儲數據(即使用基於數據庫的會話),我無法弄清楚如何使用Rack::Session::Pool
,這似乎是我需要使用的東西。
我該如何去有關轉換我的webapp使用配有游泳池?
我知道我需要添加這條線
use Rack::Session::Pool
接下來是什么? - 提前致謝!
編輯 :這是一個使用基於cookie的會話的例子:
require 'rubygems'
require 'sinatra'
enable :sessions
get '/' do
session.merge!(params)
session.inspect
end
訪問/?hi=there
然后訪問/
你仍會看到{'hi'=>'there'}
,因為它已存儲在cookie中。
只需use Rack::Session::Pool
替換行enable :sessions
。 全部enable :session
Rack::Session::Cookie
添加到堆棧(您要避免)。 session
助手仍然有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.