删除Rails 3子域Cookie
问题描述:
我遇到了一些用户在我的域中有多个会话cookie的问题。删除Rails 3子域Cookie
in session_store我们做了不是最初使用domain: :all
。
因此,用户有时会结束与饼干域example.com
和www.example.com
对于出现场,特定子域饼干并不重要。我只想为整个网站提供一个cookie。
如果我只是更改session_store来添加domain: all
,它并不一定意味着现有的Cookie消失。事实上,用户可能现在有第三个饼干,现在有一个example.com
,www.example.com
和.example.com
鉴于饼干RFC写入的方式,以及如何机架工具处理Cookie,错了,旧的cookie可以被加载时用户请求被做出。 It just loads up the 'first' one in the cookie string from the header.
因此......有谁知道从用户浏览器中删除旧cookies的可靠方法。具体而言,我想删除域www.example.com
和example.com
中的Cookie,同时保留.example.com
的Cookie。
谢谢。
答
如何更改密钥以存储会话?
YourApplication.config.session_store :cookie_store, key: '_your_new_session_key', domain: :all, tld_length: 2