删除子域的cookie
我有一个域名,例如:example.com 我有子域:sub.example.com
网站上的用户共享相同的会话和内容曲奇饼, 但我怎样才能从两个域中删除cookie呢?
现在我从一个域中删除,当子域消失时,他再次登录..
非常感谢。什洛米
i have a domain for example : example.com
and i have sub-domain : sub.example.com
the users on the site is sharing the same session & cookies,
but how can i remove cookies from both the domains ?
for now i delete from one domain and when the goes the the sub-domain he is logged in again ..
much thanks. shlomi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过将 cookie 的到期日期设置为已经过去的日期时间来删除 cookie。您可以对子域执行相同的操作。
澄清一下,路径是相对于主域的路径。您的“子”应该是主域内的文件夹。
sub.example.com
实际上类似于 exampleRoot/sub/,因此这是您放入 cookie 的路径,并且您将日期时间设置为旧日期时间以从该子域中删除 cookie。You can delete a cookie by setting it's expiration date to a datetime that has already been passed. You can do the same for a subdomain.
To clarify, the path is the path relative to the main domain. You "sub" should be a folder inside the main domain.
sub.example.com
is in fact something like exampleRoot/sub/ so this is the Path you put to your cookie and you set the datetime to an old datetime to remove the cookie from this subdomain.