Wednesday, September 24, 2008

Re-enabling cookie_only in Rails 2.1+

Somewhere along the line the 'cookie_only' option stopped working in Rails. I have needed this param to let me pass the session id in the query string or in a post parameter a couple of times recently, usually b/c I'm developing something in an iframe and 3rd party cookies aren't an option. There are a couple of solutions out there as to how to get this to work, but none that I found took into account the cookie_only option and they also usually monkey patch the cgi session instead of a part of Rails itself. I created this version of the session method from cgi_request.rb in Rails - you can drop the below code into a file in config/initializers::

1 comment:

Unknown said...

Thanks! I tried about 18 other options to get a Flash uploader (Uploadify) to play nice with Rails... This works nicely and I think you're right to monkeypatch Rails itself not just the Session...