Search code examples
ruby-on-railsdevise

Setting session length with Devise


My sessions with devise timeout after 1-3 hours of non-use (not sure exactly how long). How can I adjust this?

I've looked over the docs and can't seem to find a setting for this.


Solution

  • Look in config/initializers/devise.rb. There are a lot of configuration settings including config.timeout_in. The default in my version is 30 minutes. You can also set it on the model itself:

    class User < ActiveRecord::Base
      devise :timeoutable, :timeout_in => 15.minutes
    

    You can now also set the timeout dynamically.