<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Cookie handling in multi-domain applications in Ruby on Rails</title>
	<atom:link href="http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/</link>
	<description>The blog with the bug.</description>
	<lastBuildDate>Mon, 26 Oct 2009 20:00:20 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Michal</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-1025</link>
		<dc:creator>Michal</dc:creator>
		<pubDate>Fri, 17 Apr 2009 13:42:55 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-1025</guid>
		<description>If your using Rails 2.3 or any other framework that utilizes Rack, this could be useful:
http://codetunes.com/2009/04/17/dynamic-cookie-domains-with-racks-middleware/</description>
		<content:encoded><![CDATA[<p>If your using Rails 2.3 or any other framework that utilizes Rack, this could be useful:<br />
<a href="http://codetunes.com/2009/04/17/dynamic-cookie-domains-with-racks-middleware/" rel="nofollow">http://codetunes.com/2009/04/17/dynamic-cookie-domains-with-racks-middleware/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kareem</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-1020</link>
		<dc:creator>kareem</dc:creator>
		<pubDate>Tue, 31 Mar 2009 22:18:21 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-1020</guid>
		<description>thanks for updating your code for 2.3.2 , brendan</description>
		<content:encoded><![CDATA[<p>thanks for updating your code for 2.3.2 , brendan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brendan Schwartz</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-1008</link>
		<dc:creator>Brendan Schwartz</dc:creator>
		<pubDate>Mon, 23 Mar 2009 19:47:08 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-1008</guid>
		<description>If anyone stumbles upon this article, I&#039;ve updated this code to work with Rails 2.3.2. See: http://gist.github.com/64874</description>
		<content:encoded><![CDATA[<p>If anyone stumbles upon this article, I&#8217;ve updated this code to work with Rails 2.3.2. See: <a href="http://gist.github.com/64874" rel="nofollow">http://gist.github.com/64874</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szeryf</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-1007</link>
		<dc:creator>szeryf</dc:creator>
		<pubDate>Mon, 23 Mar 2009 19:23:06 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-1007</guid>
		<description>None of the above works with the version of Rails that you use? See http://rubista.info/post/88299744/varios-dominios-e-uma-unica-aplicacao-rails-com for more examples (no, I don&#039;t understand this article either :)</description>
		<content:encoded><![CDATA[<p>None of the above works with the version of Rails that you use? See <a href="http://rubista.info/post/88299744/varios-dominios-e-uma-unica-aplicacao-rails-com" rel="nofollow">http://rubista.info/post/88299744/varios-dominios-e-uma-unica-aplicacao-rails-com</a> for more examples (no, I don&#8217;t understand this article either :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szeryf</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-979</link>
		<dc:creator>szeryf</dc:creator>
		<pubDate>Mon, 16 Feb 2009 08:16:47 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-979</guid>
		<description>Brendan: thanks, much appreciated.</description>
		<content:encoded><![CDATA[<p>Brendan: thanks, much appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brendan Schwartz</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-978</link>
		<dc:creator>Brendan Schwartz</dc:creator>
		<pubDate>Sun, 15 Feb 2009 22:05:46 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-978</guid>
		<description>^ Minus the &lt;code&gt;puts &quot;DOMAIN: #{domain}&quot;&lt;/code&gt; line of course.</description>
		<content:encoded><![CDATA[<p>^ Minus the <code>puts "DOMAIN: #{domain}"</code> line of course.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brendan Schwartz</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-977</link>
		<dc:creator>Brendan Schwartz</dc:creator>
		<pubDate>Sun, 15 Feb 2009 22:03:40 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-977</guid>
		<description>Adjusted to work with Rails 2.3. Hopefully this will save someone a 30 minute code dive.

[sourcecode language=&#039;ruby&#039;]
module ActionControllerExtensions
  def self.included(base)
    base::Dispatcher.send :include, DispatcherExtensions
  end

  module DispatcherExtensions
    def self.included(base)
      base.send :before_dispatch, :set_session_domain
    end

    def set_session_domain
      domain = @env[&#039;HTTP_HOST&#039;].gsub(/:\d+$/, &#039;&#039;).gsub(/^[^.]*/, &#039;&#039;)
      puts &quot;DOMAIN: #{domain}&quot;
      @env[&#039;rack.session.options&#039;].update :domain =&gt; domain
    end
  end
end

ActionController.send :include, ActionControllerExtensions
[/sourcecode]</description>
		<content:encoded><![CDATA[<p>Adjusted to work with Rails 2.3. Hopefully this will save someone a 30 minute code dive.</p>
<pre class="brush: ruby;">
module ActionControllerExtensions
  def self.included(base)
    base::Dispatcher.send :include, DispatcherExtensions
  end

  module DispatcherExtensions
    def self.included(base)
      base.send :before_dispatch, :set_session_domain
    end

    def set_session_domain
      domain = @env['HTTP_HOST'].gsub(/:\d+$/, '').gsub(/^[^.]*/, '')
      puts "DOMAIN: #{domain}"
      @env['rack.session.options'].update :domain =&gt; domain
    end
  end
end

ActionController.send :include, ActionControllerExtensions
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subdomains and rails &#171; Jabberwocky</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-713</link>
		<dc:creator>Subdomains and rails &#171; Jabberwocky</dc:creator>
		<pubDate>Mon, 13 Oct 2008 13:37:51 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-713</guid>
		<description>[...] out throughout your site (regardless of subdomains), you could use a small amendement as in this link.  However, that may not be what you need - sometimes you want to keep the worlds separated, so [...]</description>
		<content:encoded><![CDATA[<p>[...] out throughout your site (regardless of subdomains), you could use a small amendement as in this link.  However, that may not be what you need &#8211; sometimes you want to keep the worlds separated, so [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2008-07-17 &#124; Libin Pan</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-626</link>
		<dc:creator>links for 2008-07-17 &#124; Libin Pan</dc:creator>
		<pubDate>Thu, 17 Jul 2008 06:32:17 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-626</guid>
		<description>[...] Cookie handling in multi-domain applications in Ruby on Rails « require ‘brain’ Cookie handling in multi-domain applications in Ruby on Rails (tags: cookies development programming rails ror ruby scalability subdomain rubyonrails sessions cookie) [...]</description>
		<content:encoded><![CDATA[<p>[...] Cookie handling in multi-domain applications in Ruby on Rails « require ‘brain’ Cookie handling in multi-domain applications in Ruby on Rails (tags: cookies development programming rails ror ruby scalability subdomain rubyonrails sessions cookie) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luke Francl</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-624</link>
		<dc:creator>Luke Francl</dc:creator>
		<pubDate>Wed, 16 Jul 2008 18:29:40 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-624</guid>
		<description>This is an interesting technique, I wish I had seen this earlier.

I tried to do a similar thing by hacking Rails session code so that the session domain could be specified with a Proc in the controller. It worked for sending cookies, but I was having trouble reconstituting them.

For developing on localhost with subdomains, I also ran into the invalid authenticity token problems, which we just worked around by creating an alias in /etc/hosts and accessing the site from there, with the session domain configured appropriately of course.</description>
		<content:encoded><![CDATA[<p>This is an interesting technique, I wish I had seen this earlier.</p>
<p>I tried to do a similar thing by hacking Rails session code so that the session domain could be specified with a Proc in the controller. It worked for sending cookies, but I was having trouble reconstituting them.</p>
<p>For developing on localhost with subdomains, I also ran into the invalid authenticity token problems, which we just worked around by creating an alias in /etc/hosts and accessing the site from there, with the session domain configured appropriately of course.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mat</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-623</link>
		<dc:creator>Mat</dc:creator>
		<pubDate>Wed, 16 Jul 2008 12:39:57 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-623</guid>
		<description>Great post - as well as the internationalization bit, this is helpful for anyone who uses subdomains but deploys to different top-level domains for development, testing, and production.

One important fact (explained in the linked &quot;localhost &amp; cookies&quot; post above) is that this won&#039;t work for localhost - in fact, if you try, your session won&#039;t be saved at all, and you&#039;ll have InvalidAuthenticityToken problems if you use authenticity checking.

Also, I think it&#039;s always better to extend classes rather than reopen them - so, with those two things in mind, here&#039;s a slight refactor (works fine in Rails 2.1):
[sourcecode language=&#039;ruby&#039;]
module ActionControllerExtensions
  def self.included(base)
    base::Dispatcher.send :include, DispatcherExtensions
  end
  
  module DispatcherExtensions
    def self.included(base)
      base.send :before_dispatch, :set_session_domain
    end
    
    def set_session_domain
      ApplicationController.session_options.update :session_domain =&gt; &quot;#{@request.host.gsub(/^[^.]*/, &#039;&#039;)}&quot; unless request.host.match /\.localhost$/
    end
  end
end

ActionController.send :include, ActionControllerExtensions
[/sourcecode]</description>
		<content:encoded><![CDATA[<p>Great post &#8211; as well as the internationalization bit, this is helpful for anyone who uses subdomains but deploys to different top-level domains for development, testing, and production.</p>
<p>One important fact (explained in the linked &#8220;localhost &amp; cookies&#8221; post above) is that this won&#8217;t work for localhost &#8211; in fact, if you try, your session won&#8217;t be saved at all, and you&#8217;ll have InvalidAuthenticityToken problems if you use authenticity checking.</p>
<p>Also, I think it&#8217;s always better to extend classes rather than reopen them &#8211; so, with those two things in mind, here&#8217;s a slight refactor (works fine in Rails 2.1):</p>
<pre class="brush: ruby;">
module ActionControllerExtensions
  def self.included(base)
    base::Dispatcher.send :include, DispatcherExtensions
  end

  module DispatcherExtensions
    def self.included(base)
      base.send :before_dispatch, :set_session_domain
    end

    def set_session_domain
      ApplicationController.session_options.update :session_domain =&gt; "#{@request.host.gsub(/^[^.]*/, '')}" unless request.host.match /\.localhost$/
    end
  end
end

ActionController.send :include, ActionControllerExtensions
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eduardo Bellani</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-584</link>
		<dc:creator>Eduardo Bellani</dc:creator>
		<pubDate>Wed, 11 Jun 2008 02:03:51 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-584</guid>
		<description>Hey guys.
If anybody is having trouble with rails 2.0.2, I&#039;ve come up with a working hack(and also changed some cosmetic stuff)
[sourcecode language=&#039;ruby&#039;]
require &#039;activesupport&#039; 
require &#039;dispatcher&#039;
module ActionController
  class Dispatcher
    def set_session_domain
      ActionController::Base.session_options[:session_domain] = &quot;#{@request.domain}&quot;
    end 
    before_dispatch :set_session_domain
  end
end
[/sourcecode]</description>
		<content:encoded><![CDATA[<p>Hey guys.<br />
If anybody is having trouble with rails 2.0.2, I&#8217;ve come up with a working hack(and also changed some cosmetic stuff)</p>
<pre class="brush: ruby;">
require 'activesupport'
require 'dispatcher'
module ActionController
  class Dispatcher
    def set_session_domain
      ActionController::Base.session_options[:session_domain] = "#{@request.domain}"
    end
    before_dispatch :set_session_domain
  end
end
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-566</link>
		<dc:creator>Aaron</dc:creator>
		<pubDate>Tue, 29 Apr 2008 14:42:24 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-566</guid>
		<description>This now fails in Edge Rails with:
uninitialized constant ActionController::Dispatcher::ApplicationController

not sure why</description>
		<content:encoded><![CDATA[<p>This now fails in Edge Rails with:<br />
uninitialized constant ActionController::Dispatcher::ApplicationController</p>
<p>not sure why</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacek Becela</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-437</link>
		<dc:creator>Jacek Becela</dc:creator>
		<pubDate>Thu, 31 Jan 2008 17:56:14 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-437</guid>
		<description>We&#039;ve  used GetText in the past but hell, it feels do &#039;97. Try Gibberish. Much simpler, No compilation, no .po, .mo madness.</description>
		<content:encoded><![CDATA[<p>We&#8217;ve  used GetText in the past but hell, it feels do &#8216;97. Try Gibberish. Much simpler, No compilation, no .po, .mo madness.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szeryf</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-434</link>
		<dc:creator>szeryf</dc:creator>
		<pubDate>Mon, 21 Jan 2008 15:34:58 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-434</guid>
		<description>rdempsey: We use GetText. It stores its translations in special files. It&#039;s not that bad. At least most of the translation work can be done without assistance of programmers. 

I think that maintaining several language version of any application is quite a lot work. There are several plugins of this type but since I haven&#039;t tried any other of them (except GetText) I can&#039;t tell if they are much better or worse.</description>
		<content:encoded><![CDATA[<p>rdempsey: We use GetText. It stores its translations in special files. It&#8217;s not that bad. At least most of the translation work can be done without assistance of programmers. </p>
<p>I think that maintaining several language version of any application is quite a lot work. There are several plugins of this type but since I haven&#8217;t tried any other of them (except GetText) I can&#8217;t tell if they are much better or worse.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rdempsey</title>
		<link>http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-433</link>
		<dc:creator>rdempsey</dc:creator>
		<pubDate>Mon, 21 Jan 2008 15:00:31 +0000</pubDate>
		<guid isPermaLink="false">http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/#comment-433</guid>
		<description>Very cool, thanks. Any advice on supporting multiple languages (globalization) in a single Rails application would be greatly appreciated too. I know that it used to be a PITA to support multiple languages (keep all copy in the database in each language). Has it gotten any better?</description>
		<content:encoded><![CDATA[<p>Very cool, thanks. Any advice on supporting multiple languages (globalization) in a single Rails application would be greatly appreciated too. I know that it used to be a PITA to support multiple languages (keep all copy in the database in each language). Has it gotten any better?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
