开发者

WinInet and SessionCookies

Hello and good evening to all.

I have my app that uses InternetSetCookie to create (session) cookies needed for its job. However I want to remove the cookie named for ex. 'badcookie' after each request via

InternetSetCookie("http://www.domain.com", "badcookie", ""); and InternetSetCookie("http://www.domain开发者_如何学Python.com", NULL, "badcookie=")

but...in best case it will send cookie w/o any value and thats that.

My question is how to completly remove this cookie? (No, I dont want to make them permanent and call cleanup() 10 times, maybe I would create thread for each request but its akward if I do it)


InternetSetCookie("http://domain.com", NULL, "badcookie=bye; expires = Sat,01-Jan-1970 00:00:00 GMT");

This removed the complete txt file with some other cookies inside. Before I was using www.domain.com and I saw that it was problem... now I face same issue as the link you posted (lossing more cookies) but my question is answered now.

PS This works with session cookies too.


My answer isn't 100% complete, but maybe it's a start. I'd suggest setting the expiration of the cookie to be in the past, as this will force the client to clear the cookie. I'm not familiar with WinINET syntax, so maybe someone has a better answer. I'm more of an ASP.NET person - but this article seems to suggest how to expire the cookie.

Based on gaor's response to my initial comment, sounds like there's still a little more work to do to completely fix this. But hopefully this helps and gets someone pointed in the right direction.

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜