Turn off Rails sessions by request type

Here is a solution to turn sessions off based on a request type. I added this to application.rb file:

session :off,
  :if => Proc.new { |req| ['xml', 'rss'].include?(req.params[:format]) }

You could ideally just add this to an individual controller, and add :only or :except to it as well, but I wanted to eliminate all of the controllers and actions.

1 thought on “Turn off Rails sessions by request type

Leave a Reply

Your email address will not be published. Required fields are marked *