Return to Snippet

Revision: 1265
at September 27, 2006 09:25 by gdonald


Updated Code
before_filter :session_expire

private

def session_expire
  if session[:user]
    session_length = 60*10 #10 Minutes for logged in users
    expire_time = session[:expire_time] || Time.now + 10
    if expire_time < Time.now
      reset_session
      flash[:notice] = "You have been logged out due to an extended period of inactivity"
      redirect_to :controller => 'welcome' , :action => 'index'
    else
      session[:expire_time] = Time.now + session_length
    end
  end
end

Revision: 1264
at September 27, 2006 09:23 by gdonald


Initial Code
before_filter :session_expire

private

def session_expire
if session[:user]
session_length = 60*10 #10 Minutes for logged in users
expire_time = session[:expire_time] || Time.now + 10
if expire_time < Time.now
reset_session
flash[:notice] = "You have been logged out due to an extended period of inactivity"
redirect_to :controller => 'welcome' , :action => 'index'
else
session[:expire_time] = Time.now + session_length
end
end
end

Initial URL

                                

Initial Description

                                

Initial Title
ruby session expire

Initial Tags

                                

Initial Language
Ruby