3 Rails 3 plugin that lets you set how long you want your session to be persisted/remembered.
5 session_expires_after 2.weeks
6 session_expires_automatically # also aliased to expire_session
8 The timespan will reset on every request. If you set it to 2 weeks, and the user returns after 1 week, the session will be refreshed and last 2 weeks again. If the user returns after 3 weeks, the session will be reset.
10 A call to session_expires_automatically will return to a normal automatical expiry cookie, that will expire when the browser is closed.
12 Note: I haven't tested the plugin with memcache session storage, but it should work there as well.
16 Here's an example sessions controller in a Rails 3 application.
18 class SessionsController < ApplicationController
20 session_expires_after 2.weeks if params[:remember_me]
22 # ..normal auth goes here..
24 user = User.authenticate(params[:username], params[:password])
26 session[:user] = user.id
33 session_expires_automatically
35 # ..unauthorize here..