How to remove cookie with underscore in name in VB6?
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?
That's probably because you have a ` character before your cookie name in your code.
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"))
Avoids the error in the Response.Cookies object. sCookieName can have _ and . in it with no problems!
精彩评论