This project is archived and is in readonly mode.

#6196 ✓committed
Ravil Bayramgalin

[PATCH] Improve support for non-standard domain names

Reported by Ravil Bayramgalin | December 19th, 2010 @ 07:57 PM | in 3.1

Currently when setting domain :all option Rails uses regexp which handles correctly australian and uk styles tld. It is plenty for default behavior, but sometimes we want to use different logic.

For example when dealing with domain like the cookie will be set for domain which is not correct. Another example - it will be set as And there are plenty of exceptions like this as you can see at

So I propose a couple of patches to add more flexibility.

First patch adds support for supplying several domain names to cookies. For example,

:domain => %w(

And it will set appropriate domain for all cookies.

Second patch adds more flexibility when you deal with wildcard subdomains and they are not correctly parsed by default domain regexp. For example, your application is deployed to and your application supports subdomains on top so you want to share cookies only between subdomains on top of your application. It's easy to achieve by using custom tld length:

:domain => :all, :tld_length => 3

and it will correctly set cookies domain to - first patch - second patch

If there is anything I could do to improve these patches I would be happy to do it.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

Referenced by