IIS 中虚拟目录的 Cookie 问题(删除不需要的 Cookie)
我刚刚做了一个小噩梦,不知何故创建了不需要的饼干。 我发誓我的代码从未在某个虚拟目录中创建过 cookie,它只是读取它,但不知何故,我的浏览器最终得到了一个 root cookie 和该 vdir 的该 cookie 的副本。 这意味着这两个值是分开的并且不会同时更新。
大多数关于删除cookie的文章都说将其设置为空白,但这没有帮助,因为它仍然存在!
我必须编写一个简短的 ASP 将 cookie 过期时间设置为去年,并确保我将路径指定为有问题的 vdir,以确保它杀死了我不想要的那个。
Response.Cookies("BWWF2")("UID") = ""
Response.Cookies("BWWF2").Path = "/community"
Response.Cookies("BWWF2").Expires = DateAdd("yyyy", -1, Now())
希望这已经解决了问题,但我想在这里分享这个,并询问是否有人有更好的方法来解决这个问题,或者关于这个问题(两个cookie)最初是如何发生的有什么想法吗?!
I've just had a small nightmare with unwanted cookies somehow being created. I swear my code never created a cookie in a certain virtual directory, it just read it, but somehow my browser ended up with a root cookie and a copy of this cookie for the vdir too. Which meant the two values were separate and did not both get updated.
Most articles about deleting cookies say to set it to blank, which is no help, as it will still exist!
I had to write a short ASP to set the cookie expiry to last year, and also make sure I specified the path as the vdir in question, to make sure it killed the one I didn't want.
Response.Cookies("BWWF2")("UID") = ""
Response.Cookies("BWWF2").Path = "/community"
Response.Cookies("BWWF2").Expires = DateAdd("yyyy", -1, Now())
Hopefully this has solved the problem, but I wanted to share this here, and also ask if anyone has a better way to solve the issue, or any ideas on how the problem (two cookies) might have happened in the first place?!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该检查这些虚拟目录上的 IIS 设置,并将应用程序名称设置为“默认应用程序”
。如果应用程序名称与站点的其余部分不同,则在进入虚拟目录时您将获得新的 cookie 和 sessionId。
You should check you IIS settings on those virtual directorys, and set the Application name to "Default Application"
You will get a new cookie and sessionId when entering a Virtual Direcotry if the Application name is different then the rest of the site.