title: Implementation of "Remember me" in a Rails application
body: <p>My Rails-app has a sign in box with a "remember me" checkbox. Users who check that box should remain logged in even after closing their browser. I'm keeping track of whether users are logged in by storing their id in the user's session. </p>
  
  <p>But sessions are implemented in Rails as session cookies, which are not persistent. I can <em>make</em> them persistent:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    before_filter :update_session_expiration_date
  
    private
  
    def update_session_expiration_date
      options = ActionController::Base.session_options
      unless options[:session_expires]
        options[:session_expires] = 1.year.from_now
      end
    end
  end
  </code></pre>
  
  <p>But that seems like a hack, which is surprising for such common functionality. Is there any better way?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Gareth's answer is pretty good, but I would still like an answer from someone familiar with Rails 2 (because of it's unique <code>CookieSessionStore</code>).</p>