Discussion:
Must I use a path= to clear cookies with InternetSetCookie?
(too old to reply)
William
2007-07-20 16:54:04 UTC
Permalink
I am clearing cookies in the WinInet cookie cache by setting an expired
cookie with
InternetSetCookie, but if I don't include a path= parameter, then it clears
too many cookies.
If I have two cookies with the same name, but one is for /xxx and the other
is for /yyy
(I.E. the cookies were sent by the server with those as the paths.), and I
call:
InternetSetCookie(http://.../xxx/, <expired version of cookie c>) it
sometimes just
clears the /xxx cookie, and sometimes it clears both cookies. But if I
include a path=/xxx
it seems to work reliably, but that seems bizzare, and I am not sure if that
really works,
or if it just seemed to work the few times that I did it.
Vladimir Scherbina [MVP]
2007-07-27 16:19:35 UTC
Permalink
Can you specify an example source code how do you do this?
--
Vladimir, Windows SDK MVP
http://msmvps.com/blogs/v_scherbina/
Post by William
I am clearing cookies in the WinInet cookie cache by setting an expired
cookie with
InternetSetCookie, but if I don't include a path= parameter, then it clears
too many cookies.
If I have two cookies with the same name, but one is for /xxx and the other
is for /yyy
(I.E. the cookies were sent by the server with those as the paths.), and I
InternetSetCookie(http://.../xxx/, <expired version of cookie c>) it
sometimes just
clears the /xxx cookie, and sometimes it clears both cookies. But if I
include a path=/xxx
it seems to work reliably, but that seems bizzare, and I am not sure if that
really works,
or if it just seemed to work the few times that I did it.
William
2007-07-27 21:02:02 UTC
Permalink
I don't have severable samples that do this...but it is not hard to do,
set a cookie (with an expiration date and path) by loading a CGI that
sends a Set-Cookie. Then do the same thing from a different path (and
with a different path in the cookie) on the same web server. Now call
InternetSetCookie(<url to one of the CGIs>, "<cookie-name>=;
expires=<1970>") and
watch it sometimes delete both cookies, and sometimes only delete one.
Then repeat, but do the clearing with: InternetSetCookie(<url to one of the
CGIs>,
"<cookie-name>=; path=<path>; expires=<1970>") and watch it only delete the
cookie that it should have in either case.

Loading...