Reputation: 1357
I have a rails app running on version: 5.2.1 My app is not keeping persistent session and users need to re-login frequently (few times a week).
I would like to keep user sessions forever (or at least for few years) until the user signout by herself.
I haven't changed any parameters regarding to session period so I assume it is on default settings. Here I will appreciate if you can guide me how to change session period on my app.
I use devise for login, and here is the User Model configuration:
class User < ApplicationRecord
attr_accessor :admin_user, :auth_login
has_ancestry
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
Upvotes: 1
Views: 78
Reputation: 441
Notice the modules listed in the comment above the devise configurations in the User model. You can use those modules without using an extra gem. Uncomment the :timeoutable
module and set the desired timeout in devise.rb :
# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again. Default is 30 minutes.
config.timeout_in = 3.years
Upvotes: 2