LoginSignup
5
6

More than 5 years have passed since last update.

複数ドメインで運用するRailsアプリのcookieのドメイン指定

Posted at

状況

1つのRailsアプリを複数ドメインで運用する、
というケースがどの程度あるかはわからないが、
www.foo.comwww.bar.orgで運用しているときの
cookiesdomainに対する制約を適切に設定したい

cookiesの基本的な使い方

cookies[:foo] = {
                  value: 'xxx',
                  path: '/qiita',
                  secure: true,
                  domain: 'www.foo.com',
                  expires: 1.second.from_now
                }

設定方法

こちらを参考に、以下のように記述

cookies[:foo] = {
                  value: 'xxx',
                  domain: %w(.foo.com .bar.org)
                }

どうやらRails3.1から設定できるようになっているようですね :smiley:

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6