Sinatra 启用:会话不适用于乘客/apache
我在启用 :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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管我们没有使用 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.
我出现这个问题是因为我在错误的配置区域启用了会话。我的配置如下所示:
通过将
enable :sessions
移出:development
特定配置会话开始为我工作:This issue occurred for me because I had enabled sessions in the wrong configuration area. My configuration looked like this:
By moving
enable :sessions
out of the:development
specific configuration sessions started working for me: