Passage of a session in rails 2.3.2. Subdomain use

I have an application 2.2.3 that I updated to 2.3.2

This is a multi-site (using a subdomain) that creates one top-level session for all sites.

This is how I change the domain in production.rb:

ActionController::Base.session_options[:domain] = "example.com"

# in rails 2.2.2, this is what i used to do:
# ActionController::Base.session_options[:session_domain] = "example.com" 

Strange things began to happen after I updated. I can no longer log in using quiet authentication; it authenticates me, but as soon as I am redirected, it will ask me to log in again.

As I said, I use restful_authentication and I also use passenger 2.1.2. Can anyone help?

+5
source share
10 answers

, 2.3 :

config.action_controller.session[:domain] = '.example.com'

, , :

undefined method `[]=' for nil:NilClass

( ):

config.action_controller.session ||= {}
config.action_controller.session[:domain] = '.example.com'

: -, Rails 2.2.2 - . "domain" "session_domain" . :

config.action_controller.session ||= {}
config.action_controller.session[:session_domain] = 'example.com'
+7

Rails 2.3

config.action_controller.session[:domain] = '.example.com'
+3

, . , .

if ActionController::Base.session
  ActionController::Base.session[:domain] = '.example.com'
else
  ActionController::Base.session = { :domain => '.example.com' }
end

.

+2

:

.example.com

( ), cookie example.com, .

+1

, cookie . 2.3.4.

- environment.rb

# solution to use the cookies in the api. domains
# this is relevant but in 2.3.4 the code is different
# http://szeryf.wordpress.com/2008/01/21/cookie-handling-in-multi-domain-applications-in-ruby-on-rails/
# Just making sure that api. shares the domain name
require 'dispatcher'
module ActionController
  class Dispatcher
    def set_session_domain
      host_name = @env['SERVER_NAME']
      new_host_name = whatever #some mod of the host_name, for instance
      ActionController::Base.session = {
        :domain => new_host_name
      }
    end

    before_dispatch :set_session_domain
  end
end
+1

Rails 2.3.5

config.action_controller.session = {:domain => '.localhost:3000'}

development.rb, ?

- ?

+1

( , ), nginx + thin. apache + ( ).

0

2.3.5 @alfred-nerstu

@schickm, , , .

0

,

config.action_controller.session = {
      :key => '_app_session',
      :domain => '.domain.com',
      :secret => 'secret'
}
0

cookie. Passenger 2.1.3, , .

-1

All Articles