25

Persistent Rails cookie session

http://feeds.dzone.com

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

Read »
Created by macbeth Created 27 weeks 6 days ago – Made popular 27 weeks 6 days ago
Category: Programming   Tags: