Posted By

gdonald on 09/27/06


Tagged

session expire


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

adam_dc
shovanjoshi
sergeizen
webstic


ruby session expire


 / Published in: Ruby
 

  1. before_filter :session_expire
  2.  
  3. private
  4.  
  5. def session_expire
  6. if session[:user]
  7. session_length = 60*10 #10 Minutes for logged in users
  8. expire_time = session[:expire_time] || Time.now + 10
  9. if expire_time < Time.now
  10. reset_session
  11. flash[:notice] = "You have been logged out due to an extended period of inactivity"
  12. redirect_to :controller => 'welcome' , :action => 'index'
  13. else
  14. session[:expire_time] = Time.now + session_length
  15. end
  16. end
  17. end

Report this snippet  

You need to login to post a comment.