[Rails] Session timeout setting in devise
Session timeout setting in devise
table of contents
- Benefits of setting a session timeout
- Disadvantages of setting session timeout
- Session timeout setting in devise
1. Benefits of setting a session timeout
- It is a countermeasure against fraudulent activities such as session theft, and the application can be operated safely.
- By judging the status of the user, the burden on the server side can be reduced.
2. Disadvantages of setting session timeout
- In the input form, etc., it is not possible to interrupt once and then input after resuming.
- If the login status expires many times, the user will have to log in again, and it will be judged that the application is not easy to use.
3. Session timeout setting in devise
3-1. Set Devise session timeout
Enter the following description.
(Since it is commented out, it is OK if you uncomment it)
config/initializers/devise.rb
config.timeout_in = 30.minutes
3-2. Set "timeoutable" in User model
Enter the following description.
app/models/user.rb
class User < ApplicationRecord
devise :database_authenticatable, :registerable,...abridgement...:timeoutable
end
- It is recommended to set it in 1 minute when performing the test.
This is the session timeout setting for devise.