Session not destroyed when closing browser - RailsTutorial.org

谁说胖子不能爱 提交于 2019-11-29 11:24:19

Please, check your config/initializers/session_store.rb file. There should be something like

Rails.application.config.session_store :cookie_store, key: '_app_session'

You have to add expire_after key with nil value to the options:

Rails.application.config.session_store :cookie_store, key: '_app_session', expire_after: nil

After applying this change, the session will expire when user closes the browser. You can read more about cookies expiration here

I know I'm chiming in a good seven months late, but I had this same question, and after a little extra googling, discovered it was answered two years ago here.

The problem is a browser setting, one I imagine most everyone uses these days: "When Firefox starts, show my windows and tabs from last time" or "On startup, continue where you left off." This issue is now mentioned as a footnote in the tutorial (Chapter 8, Note 1), but the best the author has to say about it is

...of course Rails has no control over this behavior.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!