Implementation of “Remember me” in a Rails application

前端 未结 7 1051
旧时难觅i
旧时难觅i 2020-12-24 05:11

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 whet

7条回答
  •  半阙折子戏
    2020-12-24 05:31

    This worked like a charm for me:

    http://squarewheel.wordpress.com/2007/11/03/session-cookie-expiration-time-in-rails/

    Now my CookieStore sessions expire after two weeks, whereby the user must submit their login credentials again in order to be persistently logged-in for another two weeks.

    Bascially, it's as simple as:

    1. including one file in vendor/plugins directory
    2. set session expiry value in application controller using just one line

提交回复
热议问题