gpt4 book ai didi

ruby-on-rails - rails 3 : Can't seem to write cookies for top level domain :(

转载 作者:行者123 更新时间:2023-12-04 03:36:38 24 4
gpt4 key购买 nike

我将 cookie 存储设置为域 => :all,就像我在文档中可以找到的那样,它似乎有效,因为设计的身份验证可以跨多个域工作。

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

但是,当我尝试自己写入 cookie 时,它​​总是写下子域......我不明白:

enter image description here

我以最简单的方式编写 cookie:
 cookies.permanent[:remember_locale] = locale

但无论如何它都不会将它设置为顶级域,而设计丢弃的似乎可以毫无问题地管理它:(

亚历克斯

ps:我使用的是 rails 3.0.3

最佳答案

session_store 的配置仅适用于 session cookie。设置单独的 cookie 时,您还必须为该 cookie 指定域。

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

注意(从 rails 源中提取):
  # 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')

关于ruby-on-rails - rails 3 : Can't seem to write cookies for top level domain :(,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4844979/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com