Rails:仅在 www 子域上设置 cookie?
我已在 asset.domain.com 上设置了资产主机,但 cookie 似乎是随请求一起发送到 assets.domain.com 的。我在某处读到,如果您将cookie设置为domain.com,那么就会发生这种情况。
所以我想我只是尝试将 cookie 设置为 www.domain.com,以便对 assets.domain.com 的请求不会发送 cookie。 (我还有一个从domain.com到www.domain.com的永久重定向)
我如何在Rails中执行此操作?
I have set up an asset host at assets.domain.com but it appears that cookies are being sent with requests to assets.domain.com. I read somewhere that if you have cookies set to domain.com then this will happen.
So I guess I'm trying to set cookies only to www.domain.com so that requests to assets.domain.com will not send cookies. (I also have a permanent redirect from domain.com to www.domain.com)
How do I do this in Rails??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要在特定域上设置 cookie:
一个问题是,在删除特定于域的 cookie 时,您还必须指定域:
为了确保我不会忘记,我通常会创建一个帮助程序来设置和删除默认域所在的 cookie始终指定。
To set a cookie on specific domain:
One gotcha is that you must also specify the domain when you delete domain-specific cookies:
To make sure I don't forget, I usually make a helper for setting and deleting cookies where the default domain is always specified.