Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6152121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:52:04+00:00 2026-05-23T19:52:04+00:00

I have an interesting case. I’m working on white-labeling functionality for a Rails 2.3

  • 0

I have an interesting case. I’m working on white-labeling functionality for a Rails 2.3 application and have problems with setting up dynamic session domains.

So, each white-label should have own domain: company1.com, company2.com, company3.com. More over each of them should have a support for subdomains and sharing the session between them.

I.e. test1.company1.com, test2.company1.com, company1.com <= should share a common session; test1.example.com, example.com <= should share a common session but different from company1.com .

In the common case (for a single base domain) it’s done this way:

file:production.rb
config.action_controller.session[:domain] = '.company1.com'

If I want to support multiple domains I’ll have to set this config option dynamically based on the accessed site domain. I’m currently trying to accomplish it in this way:

file:environment.rb
require 'dispatcher'
module ActionController
  class Dispatcher
    def set_session_domain
      tld_size = SubdomainFu.tld_size+1
      host_name = @env['HTTP_HOST'].split('.')[-tld_size,tld_size].join('.')
      ActionController::Base.session = { :domain => ".#{host_name}" }
    end
    before_dispatch :set_session_domain
  end
end

However the above code does not work.

Have you done something similar successfully or do you have any idea where the problem/solution could be?

Thank you in advance for your time

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:52:05+00:00Added an answer on May 23, 2026 at 7:52 pm

    Using ActionController::Base.session is not going to work, because it is used only when initializing the rack middleware handling the sessions, therefore only when booting your app. In order to make the above code work you should use

    @env['rack.session.options']
    

    Have a look here for an example:

    http://railsforum.com/viewtopic.php?id=41306

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interesting case of results sets returned by SQL Server being different
I find it very interesting and have a prototype working based on Steve's mvc
Hy, all. I have an interesting case. I have tried to create a wcf
I am working on a website for a client and they have an interesting
In this case I have some code which is working without problem in an
I'm testing out an interesting threading concept in PHP. Basically, I'm working to have
I have an interesting (but frustraring) problem. I have an application which uses the
I have somewhat interesting development situation. The client and deployment server are inside a
I have an interesting problem and would appreciate your thoughts for the best solution.
I have an interesting situation where I need to deploy an ASP.NET MVC app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.