Session Lifetime plugin

Plugin details

A Rails plugin for expiring sessions on inactivity

Websitehttp://workswithruby.com/2008/10/session_lifetime-plugin Repositorygit://github.com/DefV/session_lifetime.git Author Jan De Poorter Tags session LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install git://github.com/DefV/session_lifetime.git

Example

  class ApplicationController << ActionController::Base
    expires_session
  end


Or you can give some options:

:time - After how much time of inactivity should the session be invalidated. Default is 1 hour 
:redirect_to - Where should we redirect the user to once their session has expired 
:on_expiry - Takes a Proc or a lamba which gives you a callback after the session invalidation. This is useful for setting a flash message or something in the database. 


class ApplicationController << ActionController::Base 
  expires_session :time => 2.hours, :redirect_to => '/login', :on_expiry => lambda {
    flash[:notice] = "Your session has been expired, and you have been logged out."
  }

end 


If you want a controller not to have expiring_session you can use skip_before_filter:

  class SessionController << ApplicationController
    skip_before_filter :check_session_lifetime, :only => [:new, :create]
  end

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 2 months ago