如何在VB6中删除名称中带有下划线的cookie?
我有 VB6 Web 应用程序,我必须删除 cookie。不幸的是,cookie 的名称中包含下划线字符——示例性的 cookie 名称如下所示:XXXXXXAAASS_session_key
。
当我尝试通过向其分配空值来删除它时:
Response.cookies.Item("XXXXXXAAASS_session_key") = ""
我有一个名为 XXXXXXAASS%5Fsession%5Fkey
的新 cookie(下划线编码为 %5F
),如下所示我的 Firefox 浏览器报告了(在 FF 选项中的 Cookie 视图中和请求的 Firebug 视图中)。
我还尝试使用以下代码从 Javascript 中清除此 cookie:
document.cookie = 'XXXXXXAAASS_session_key_session_key=;expires=Thu, 01-Jan-70 00:00:01 GMT;path=/';
这也不起作用:( -- 在其他域中创建 cookie。
恐怕我无法更改 cookie 名称。
现在我将尝试迭代 cookies< /code> 集合,但我不相信它会起作用:(。
知道我会做错什么吗?
I have VB6 web application and I have to remove cookie. Unfortunately cookie has underscore character in name -- exemplary cookie name looks like that: XXXXXXAAASS_session_key
.
When I try to remove it by assign empty value to it:
Response.cookies.Item("XXXXXXAAASS_session_key") = ""
I've got a new cookie with name XXXXXXAAASS%5Fsession%5Fkey
(underscore in encoded as %5F
) as my Firefox browser reported (both in Cookie view somewhere in FF options and in Firebug view of request).
I also tried to clear this cookie from Javascript with code like:
document.cookie = 'XXXXXXAAASS_session_key_session_key=;expires=Thu, 01-Jan-70 00:00:01 GMT;path=/';
This also didn't work :( -- creates cookies in other domain.
I am afraid I cannot change cookie name.
Now I will try to iterate over cookies
collection, but I don't believe it will work :(.
Any idea what I can do wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能是因为您的代码中 cookie 名称之前有一个 ` 字符。
That's probably because you have a ` character before your cookie name in your code.
问题部分地解决了...
我无法清除 cookie,因为它不是由我的应用程序/服务器设置的 - 我没有注意到:(,因为 cookie 域被设置为我的 Web 应用程序服务器名称。
这解释了为什么我无法清除它或只是创建具有相同名称的新 cookie,
但第二个问题仍然存在 - 为什么 cookie 名称是由 VB6 编码的。
Problem was solved, partly...
I could not clear the cookie because it was not set by my application/server -- I didn't notice that :(, because cookie domain was set to my web application server name.
This explains why I could not clear it or just create new cookie with the same name.
But second problem still exists -- why cookie name was encoded by VB6.
Response.AddHeader("Set-Cookie", sCookieName & "=; expires=" & Format(Now - 1, "ddd, dd-mmm-yyyy hh:mm:ss"))
避免响应中出现错误。 Cookie 对象。 sCookieName 可以有 _ 和 。没有任何问题!
Response.AddHeader("Set-Cookie", sCookieName & "=; expires=" & Format(Now - 1, "ddd, dd-mmm-yyyy hh:mm:ss"))
Avoids the error in the Response.Cookies object. sCookieName can have _ and . in it with no problems!