Rails 3: Disable session cookies
I created a controller to serve dynamic stylesheets, so I can use the image_tag helper and add some cache control.
The problem is that every time the css file is loaded at the browser, I can see开发者_StackOverflow社区 'Cookie xxx changed" message in firebug. I would like to disable or bypass session cookies for this controller.
I read somewhere that using
session :off
would do the job, but I see it is deprecated. Is there any work around?
Thanks!
Simply done by setting the session_store
to :disabled
like so:
MyApp::Application.config.session_store :disabled
That will completely disable the session as well as access to the flash
.
or one can use session :off
anyways (even in Rails 3) :
https://github.com/kares/session_off
class StylesheetsController < ActionController::Base
session :off # for all actions in this controller
end
In Rails 3 you could use ActiveControllerMetal and only include the features you need http://asciicasts.com/episodes/150-rails-metal
Here's an alternate way in 2.3 to disable sessions, by setting the session store to nil:
http://johnpwood.net/2009/09/04/disabling-sessions-in-rails-2-3-4/
Perhaps you can do the same in 3?
精彩评论