Rails 3: It does not seem to write cookies for the top-level domain :(

I set the cookie store in the domain =>: everything, as I could find in the documentation, and it seems to work, because creating authentication works across multiple domains.

MyApp::Application.config.session_store :cookie_store, :key => '_MyApp.com_session', :domain => :all

However, when I try to write to a cookie, it always writes a subdomain ... I do not understand:

enter image description here

I am writing a cookie in the simplest way:

 cookies.permanent[:remember_locale] = locale

But no matter what it will not install for the top-level domain, while the one that fell with help seems to handle this without any problems :(

Alex

ps: I am using rails 3.0.3

+3
source share
1 answer

session_store cookie . cookie cookie.

cookies.permanent[:remember_locale] = { :value => locale, :domain => :all }

( ):

  # Please note that if you specify a :domain when setting a cookie, you must also specify the domain when deleting the cookie:
  #
  #  cookies[:key] = {
  #    :value => 'a yummy cookie',
  #    :expires => 1.year.from_now,
  #    :domain => 'domain.com'
  #  }
  #
  #  cookies.delete(:key, :domain => 'domain.com')
+3

Source: https://habr.com/ru/post/1788846/


All Articles