将 Rack::Session::Pool 与 Sinatra 一起使用
我正在探索 Sinatra,我想使用会话,但我不希望它们存储在 Cookie 中,我发现 Rack::Session::Pool 效果很好。
现在我希望会话在一定时间后过期,但我不明白如何实例化 Rack::Session::Pool 并在 Sinatra 中使用它。
有什么线索吗?
I'm exploring Sinatra and I want to use sessions but I don't want them to be stored in a Cookie, I found Rack::Session::Pool which works very well.
Now I want sessions to expire after a certain duration but I don't understand how to instanciate the Rack::Session::Pool and them use it in Sinatra.
Any Clue ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Sinatra 非常强大,《邪恶跳蚤》中的技巧不起作用,但这个起作用了:
谢谢!
Sinatra is quite powerful, the trick from The Wicked Flea didn't work but this did :
Thanks !
在您的rackup文件中:
要启动,请运行
rackup app.ru
,或使用Passenger等。这应该将您的应用程序包装在会话池中并启用其功能。 我不完全知道为什么它不需要像大多数其他中间件一样使用。请注意,我根本没有测试过这个,我还没有需要会话池的东西。 我从 Rack::Session::Pool 的 文档 中编写了此内容,页面顶部有一个示例。 所以,我也无法告诉你具体如何使用它。
In your rackup file:
To launch run
rackup app.ru
, or use Passenger, etc. This ought to wrap your application in the session pool and enable its functionality. I don't entirely know why it doesn't need use like most other middleware.Understand that I haven't tested this at all, I haven't had something that needed session pools yet. I wrote this from the documentation for Rack::Session::Pool, which had an example at the top of the page. So, I can't tell you exactly how to use it either.