Skip to content

Commit

Permalink
Revert "Add support for multi-subdomain session by setting cookie hos…
Browse files Browse the repository at this point in the history
…t in session cookie so you can share session between www.example.com, example.com and user.example.com. [#4818 state:resolved]"

It does not work for domains like co.uk and com.br.

This reverts commit c4d6245.
  • Loading branch information
josevalim committed Jun 10, 2010
1 parent d93b45e commit 330a890
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 47 deletions.
5 changes: 1 addition & 4 deletions actionpack/CHANGELOG
@@ -1,10 +1,7 @@
*Rails 3.0.0 [Release Candidate] (unreleased)*

* Add support for multi-subdomain session by setting cookie host in session cookie so you can share session between www.example.com, example.com and user.example.com. #4818 [Guillermo Álvarez]
Rails 3.0.0 [Release Candidate] (unreleased)*

* Removed textilize, textilize_without_paragraph and markdown helpers. [Santiago Pastorino]


*Rails 3.0.0 [beta 4] (June 8th, 2010)*

* Remove middleware laziness [José Valim]
Expand Down
Expand Up @@ -121,12 +121,7 @@ def call(env)
unless options[:expire_after].nil?
cookie[:expires] = Time.now + options.delete(:expire_after)
end

if options[:domain] == :all
top_level_domain = env["HTTP_HOST"].split('.')[-2..-1].join('.')
options[:domain] = ".#{top_level_domain}"
end


request = ActionDispatch::Request.new(env)
set_cookie(request, cookie.merge!(options))
end
Expand Down
Expand Up @@ -34,14 +34,6 @@ module Session
# integrity defaults to 'SHA1' but may be any digest provided by OpenSSL,
# such as 'MD5', 'RIPEMD160', 'SHA256', etc.
#
# * <tt>:domain</tt>: Restrict the session cookie to certain domain level.
# If you use a schema like www.example.com and wants to share session
# with user.example.com set <tt>:domain</tt> to <tt>:all</tt>
#
# :domain => nil # Does not sets cookie domain. (default)
# :domain => :all # Allow the cookie for the top most level
# domain and subdomains.
#
# To generate a secret key for an existing application, run
# "rake secret" and set the key in config/environment.rb.
#
Expand Down
29 changes: 0 additions & 29 deletions actionpack/test/dispatch/session/cookie_store_test.rb
Expand Up @@ -185,35 +185,6 @@ def test_session_store_with_expire_after
end
end

def test_session_store_with_explicit_domain
with_test_route_set(:domain => "example.es") do
get '/set_session_value'
assert_match /domain=example\.es/, headers['Set-Cookie']
headers['Set-Cookie']
end
end

def test_session_store_without_domain
with_test_route_set do
get '/set_session_value'
assert_no_match /domain\=/, headers['Set-Cookie']
end
end

def test_session_store_with_nil_domain
with_test_route_set(:domain => nil) do
get '/set_session_value'
assert_no_match /domain\=/, headers['Set-Cookie']
end
end

def test_session_store_with_all_domains
with_test_route_set(:domain => :all) do
get '/set_session_value'
assert_match /domain=\.example\.com/, headers['Set-Cookie']
end
end

private

# Overwrite get to send SessionSecret in env hash
Expand Down

0 comments on commit 330a890

Please sign in to comment.