Sinatra 启用:会话不适用于乘客/apache

发布于 2024-08-18 07:24:52 字数 344 浏览 2 评论 0原文

我在启用 :sessions 时遇到问题,以维持在 guest/apache 上托管的简单 Sinatra 应用程序。我将会话[:authorized] 的状态存储在cookie 中。当托管在 Rack::Handler::Mongrel 上时,它可以在本地工作,但我似乎无法在乘客身上获得相同的行为。

我尝试了两种启用会话的方法,这两种方法都不适用于乘客/阿帕奇安装 启用 :sessions

使用 Rack::Session::Pool, :domain => 'example.com', :expire_after => 60 * 60 * 24 * 365

关于如何修复有什么想法吗?

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.

I've tried two methods for enabling sessions, both of which don't work on the passenger/apache installation
enable :sessions

and

use Rack::Session::Pool, :domain => 'example.com', :expire_after => 60 * 60 * 24 * 365

Any ideas on how to fix?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

穿越时光隧道 2024-08-25 07:24:52

尽管我们没有使用 Apache / Passenger(在开发模式下),但我们也面临着类似的问题。我们这样解决了这个问题 -

从 Sinatra 应用程序中注释掉 Rack::Session 命令。在 config.ru 文件中执行此操作。并且只在您的 sinatra 应用程序中启用 :sessions 。

那应该有效。

We were facing something similar although we were not using Apache / Passenger (in development mode). We resolved it like this -

Comment out the Rack::Session commands from within your Sinatra app. Do it in the config.ru file. and haven only enable :sessions in your sinatra app.

That should work.

转身以后 2024-08-25 07:24:52

我出现这个问题是因为我在错误的配置区域启用了会话。我的配置如下所示:

configure :development do
  # ... other settings ...
  enable  :sessions
end

通过将 enable :sessions 移出 :development 特定配置会话开始为我工作:

configure :development do
  # ... other settings ...
end

enable  :sessions

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

By moving enable :sessions out of the :development specific configuration sessions started working for me:

configure :development do
  # ... other settings ...
end

enable  :sessions
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文