title: Close session and redirect to login in Ruby on Rails
body: <p>I am working with <code>session[:hash_name]</code> in ruby on rails to keep session information such as username and stuff.</p>
  
  <p>I am trying to find a way to expire this session without the user having to log out. Specially in two cases: after some time it needs to expire and when the user closes the browser.</p>
  
  <p>So far I have found <a href="http://www.tutorialspoint.com/ruby-on-rails/rails-session-cookies.htm">another</a> parameter called <code>cookies[:hash_name]</code> which can expire after some time. But I'm not sure how to check this parameter in every user request and then call reset_session. When the session is reset I need to redirect the user to the login page.</p>
  
  <p>Any suggestion to solve these 2 problems are greatly appreaciated.</p>