ApplicationController:
before_filter :session_expiry, :except => [:login, :logout]
before_filter :update_activity_time, :except => [:login, :logout]
def session_expiry
@time_left = (session[:expires_at] - Time.now).to_i
unless @time_left > 0
reset_session
flash[:error] = 'Sua sessão expirou. Favor entrar novamente.'
redirect_to :controller => 'login', :action => 'login'
end
end
def update_activity_time
session[:expires_at] = 60.minutes.from_now
end
rails 设置session过期时间
最新推荐文章于 2018-07-05 10:51:00 发布