Sinatra 启用:会话不适用于乘客/apache [英] Sinatra enable :sessions not working on passenger/apache

查看:43
本文介绍了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

这篇关于Sinatra 启用:会话不适用于乘客/apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆