Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #2017 (closed defect: wontfix)

Opened 3 years ago

Last modified 3 years ago

[PATCH] Disabling sessions doesn't work

Reported by: anonymous Assigned to: David
Priority: normal Milestone:
Component: ActionPack Version: 0.13.1
Severity: normal Keywords: session
Cc:

Description

I tried to disable sessions with putting ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS=false in my environment.rb but after doing this the application won't start any longer and the following output appears in my fastcgi.crash.log:

[20/Aug/2005:10:37:53 :: 6224] Dispatcher failed to catch: undefined method `merge' for false:FalseClass (NoMethodError)

/home/sven/public_html/../config/../vendor/rails/actionpack/lib/action_controller/cgi_process.rb:132:in `session_options_with_string_keys' /home/sven/public_html/../config/../vendor/rails/actionpack/lib/action_controller/cgi_process.rb:94:in `session' /home/sven/public_html/../config/../vendor/rails/actionpack/lib/action_controller/base.rb:799:in `assign_shortcuts' /home/sven/public_html/../config/../vendor/rails/actionpack/lib/action_controller/base.rb:355:in `process_without_session_management_support' /home/sven/public_html/../config/../vendor/rails/actionpack/lib/action_controller/session_management.rb:81:in `process' /home/sven/public_html/../config/../vendor/rails/actionpack/lib/action_controller/rescue.rb:20:in `process_with_exception' /home/sven/public_html/../config/../vendor/rails/railties/lib/dispatcher.rb:34:in `dispatch' /home/sven/public_html/../config/../vendor/rails/railties/lib/fcgi_handler.rb:136:in `process_request' /home/sven/public_html/../config/../vendor/rails/railties/lib/fcgi_handler.rb:62:in `process!' /home/sven/public_html/../config/../vendor/rails/railties/lib/fcgi_handler.rb:53:in `each_cgi' /usr/lib/ruby/1.8/fcgi.rb:597:in `each' /usr/lib/ruby/1.8/fcgi.rb:597:in `each_cgi' /home/sven/public_html/../config/../vendor/rails/railties/lib/fcgi_handler.rb:53:in `process!' /home/sven/public_html/../config/../vendor/rails/railties/lib/fcgi_handler.rb:20:in `process!' /home/sven/public_html/dispatch.fcgi:24

Attachments

unbreak_no_sessions.patch (0.5 kB) - added by jeremye@bsa.ca.gov on 08/23/05 14:14:31.

Change History

08/20/05 22:06:50 changed by nzkoz

Why did you think that that would disable sessions?

Why do you need to?

08/23/05 14:13:31 changed by jeremye@bsa.ca.gov

  • summary changed from Disabling sessions doesn't work to [PATCH] Disabling sessions doesn't work.

Maybe he/she thought that because that's what it says on http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions. If you search for "rails sessions" on Google, it's the first link.

If there is no requirement for saving state information, there should be no reason to enable sessions. I have multiple sites with sessions turned off and they work fine. I'll attach a patch that fixes the problem (though there is probably be a better way to do it).

08/23/05 14:14:31 changed by jeremye@bsa.ca.gov

  • attachment unbreak_no_sessions.patch added.

09/02/05 08:59:21 changed by minam

  • status changed from new to closed.
  • resolution set to wontfix.

Unfortunately, the attached patch does not actually cause sessions to be disabled--it simply works around the reported error. The wiki page is in error--you cannot (in general) disable sessions as shown there, although that approach does work with the WEBrick server (but mostly just by chance).

The correct way to disable sessions now (in HEAD) is to:

  class ApplicationController < ActionController::Base
    session :off
  end

That will disable sessions for all controllers that extend ApplicationController.

Note that this solution does not exist in 0.13.1--you need to be running the latest edge Rails for it to work.