After closing the browser "remember me" is not working on rails with devise gem [Solved]

Generally I use devise gem in any rails application for authentication. It's so much popular and so many features. Recently I noticed that my customers are login on the websites too many times. Really I don't want to. It should store the session on browser that user should not login many times if he visits my site. Remember me option helps to users more active on the website. Generally user don't like to login again and again on a site.

Let me show you what I have done to keep user always login. on the applicationController.rb file -
class ApplicationController < ActionController::Base
include Devise::Controllers::Rememberable

def after_sign_in_remember_me(resource)
remember_me resource

Now go config/initializers/devise.rb and you will find there config.remember_me section. here I set
config.remember_me = 1.years

Now reload your server, test by login and close the browser and open the browser again. You see you are logged in ! Solution is really too easy and if you have any question you can comment here.


Popular Posts

Install and configure Network simulator (ns3) on Ubuntu 14.04