= Session Persistence

Rails 3 plugin that lets you set how long you want your session to be persisted/remembered.

 session_expires_after 2.weeks
 session_expires_automatically # also aliased to expire_session
   
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.

A call to session_expires_automatically will return to a normal automatical expiry cookie, that will expire when the browser is closed.

Note: I haven't tested the plugin with memcache session storage, but it should work there as well.

= Usage
   
Here's an example sessions controller in a Rails 3 application.

 class SessionsController < ApplicationController
  def create
    session_expires_after 2.weeks if params[:remember_me]
    
    # ..normal auth goes here..
    # for example
    user = User.authenticate(params[:username], params[:password])
    if user
      session[:user] = user.id
    else
      # ..
    end
  end
  
  def destroy
    session_expires_automatically
    
    # ..unauthorize here..
    # for example
    session[:user] = nil
    redirect_to root_path
  end
 end