forum

Home / DeveloperSection / Forums / Implementation of “Remember me” in a Rails application

Implementation of “Remember me” in a Rails application

Anonymous User223628-Dec-2014
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.

But sessions are implemented in Rails as session cookies, which are not persistent. I can make them persistent:


    class ApplicationController < 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
But that seems like a hack, which is surprising for such common functionality. Is there a better way?


Updated on 28-Dec-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By