In Ruby on Rails, it is possible to configure sharing the session cookie across multiple domains. For example in an initializer like this:
Rails.application.config.session_store :cookie_store,
key: '_your_app_session', domain: %w[a.example.tld b.example.tld]
At it is possible setting a domain option when setting a single cookie value:
cookies[:key] = { value: 'value', domain: %w[a.example.tld b.example.tld] }
But it is quite annoying using this verbose syntax each time you want to set a cookie value in the application.
I wasn't able to find any configuration or work-around to set a default domain for all cookies setter calls in the application. What I try to achieve is that I only need to configure default cookie options once and then these defaults are applied whenever I set a cookie value. For example like this:
Rails.application.config.cookie_defaults = { domain: %w[a.example.tld b.example.tld] }
cookie[:key] = 'value' # has `domain` set as expected without explicitly passed in
Is that possible in Ruby on Rails without writing a custom cookie setter method?