Ruby on Rails and the restful_authentication plugin

I am using the restful_authentication plugin for my login page. The problem is that after logging in as a user, I never log out until I log out. How to set a session timeout of 15 minutes? For example, after 15 minutes, if I go to any page, I should be redirected to the login page.

+3
source share
3 answers

You can configure the session expiration time in the config / intializers / session_store.rb file in rails 2.3.

Just add the following parameter:

:expire_after => 60.minutes

/, before_filter:

request.session_options = request.session_options.dup
request.session_options[:expire_after] = 5.minutes
request.session_options.freeze

: http://squarewheel.pl/posts/3, rails < 2.3.

+3

, cookie, ( , , rails < 2.3). , before_filter, , . , , >= 2.3

0

.rb:

  before_filter :update_activity_time, :except => [:login, :logout]

   def update_activity_time
     session[:expires_at] = 60.minutes.from_now #default 60
   end
0

Source: https://habr.com/ru/post/1709495/


All Articles