:expire_after 时间结束后 Rails 会话会发生什么? [英] What happens to Rails session after :expire_after time is up?
问题描述
会话是否变为 nil?更改是否仅对下一个请求生效?
Does the session become nil? Does the change take effect only on the next request?
我想我现在只问了三个问题...
I think I just asked three questions now...
推荐答案
您可以尝试使用类似的设置进行探索:
You can try to explore by using the similar settings:
AppName::Application.config.session_store :cookie_store, key: '_session_key', expire_after: 20.seconds
然后在浏览器中打开开发工具并转到 cookies
并选择 localhost
cookie 以查看会发生什么.
Then open up dev tools in your browser and go to cookies
and select localhost
cookies to see what happens.
我发现:
会话 cookie 在过期时间后被删除
Session cookie gets deleted after the expiration time
cookie 的过期时间会根据任何请求自动更新(重新设置)(甚至后台 ajax 请求计数)
Expiration time for a cookie gets updated automatically (re-set) upon any request (even background ajax request counts)
默认情况下,效果将在下一个请求(例如刷新页面)时发生,如果您使用典型的身份验证(例如has_secure_password_),用户应该被注销
The effect by default will take place upon the next request (refreshing the page for example) and if you use typical authentication (has_secure_password_ for example) user should be logged out
我在 ActionController::Base
上找到了最后一条评论文档页面对这个主题很有帮助
I found the last comment on the ActionController::Base
documentation page really helpful on this topic
这篇关于:expire_after 时间结束后 Rails 会话会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!