Sessions Expiring

Sessions Expiring

To improve user security, we may wish to expire the user’s session after they are inactive for a given amount of time. In order to do this, we simply set the expire_after parameter when setting up our session store. For example:

config/initializers/session_store.rb
1
Rails.application.config.session_store :cookie_store, key: '_example_session', expire_after: 15.minutes

The line above would expire the session after 15 minutes of inactivity. This means that the user’s session variables would get wiped once time reaches 15 minutes since the user last accessed the Rails application. If the user refreshes the page, the timer gets refreshed.

So far so good, That’s it!!! See ya!!! :)