Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Persistent Rails cookie session (See related posts)

Session cookies, the Rails-2 kind, are transient because that's safer. In some applications safety isn't important. The following makes the session cookies persist for a year.

class ApplicationController < ActionController::Base
  before_filter :update_session_expiration_date

private
  def update_session_expiration_date
    unless ActionController::Base.session_options[:session_expires]
      ActionController::Base.session_options[:session_expires] = 1.year.from_now
    end
  end
end

Comments on this post

ctran posts on Apr 10, 2008 at 18:42
This will change the settings for all other users so beware

You need to create an account or log in to post comments to this site.


Click here to browse all 4840 code snippets

Related Posts