Sinatra 启用:会话不适用于乘客/apache
我在启用 :sessions 时遇到了麻烦,以便为在乘客/apache 上托管的简单 Sinatra 应用程序保持持久状态.我将 session[:authorized] 的状态存储在 cookie 中.它在 Rack::Handler::Mongrel 上托管时在本地工作,但我似乎无法在乘客身上得到相同的行为.
Am having trouble getting enable :sessions to persist for a simple Sinatra app hosted on passenger/apache. I'm storing the state of session[:authorized] in a cookie. It works locally when hosted on Rack::Handler::Mongrel but I can't seem to get same behaviour on passenger.
我尝试了两种启用会话的方法,这两种方法都不适用于乘客/apache 安装启用:会话
I've tried two methods for enabling sessions, both of which don't work on the passenger/apache installation enable :sessions
和
使用 Rack::Session::Pool, :domain => 'example.com', :expire_after => 60 * 60 * 24 * 365
use Rack::Session::Pool, :domain => 'example.com', :expire_after => 60 * 60 * 24 * 365
关于如何修复的任何想法?
Any ideas on how to fix?
我出现这个问题是因为我在错误的配置区域中启用了会话.我的配置是这样的:
This issue occurred for me because I had enabled sessions in the wrong configuration area. My configuration looked like this:
configure :development do
# ... other settings ...
enable :sessions
end
通过将 enable :sessions
移出 :development
特定配置会话开始为我工作:
By moving enable :sessions
out of the :development
specific configuration sessions started working for me:
configure :development do
# ... other settings ...
end
enable :sessions