14

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 '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!

webtu
  • 219
  • 2
  • 5
  • What does your controller look like? Are you referring to the session in the controller (either in this action, or a filter) or a parent controller you're inheriting from? Session shouldn't be used unless you explicitly access it in Rails 3. – Tate Johnson Oct 23 '10 at 13:59
  • it is a normal controller (no filters) which extends < ApplicationController, the routes allow to render any css.erb file in the views directory, and applicationController is clean (no before filters) – webtu Oct 23 '10 at 15:00
  • Well, I think this only happens in development environment, as I have been working in few projects where firebug log console it's being spammed with cookie session changes but when moving to production it doesn't happen. Can anyone confirm it? Thanks in advance – webtu Feb 11 '11 at 21:02
  • 1
    Related/duplicate: http://stackoverflow.com/questions/5435494/rails-3-disabling-session-cookies – Jo Liss Feb 09 '12 at 01:33

4 Answers4

11

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.

stve
  • 219
  • 2
  • 4
4

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
kares
  • 7,076
  • 1
  • 28
  • 38
1

In Rails 3 you could use ActiveControllerMetal and only include the features you need http://asciicasts.com/episodes/150-rails-metal

Fonsan
  • 121
  • 2
0

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?

jemminger
  • 5,133
  • 4
  • 26
  • 47