How to clear a cookie programatically?
I am using silverlight unit tests to test an important part of our site. Is it possible to clear cookies before each unit test runs?
The problem is that if I do this,
HtmlPage.Document.Cookies = "";
It doesn't work. If the cookie already was this,
key = value
I can do this,
HtmlPage.Document.Cookies = "key=";
It kind of clears it out, but the string "key" is still part of the cookie.
Any ideas?
Are there any other classes in .NET that deal with cookies? The functionality seems quite limited when I am dealing with more complicate开发者_如何转开发d scenarios.
To delete existing cookie we actually just set its expiration time to some time in the past.
Jim McCurdy wrote a few classes that make the manipulation of cookies in Silverlight easier. See his Cookies for Silverlight post. There is a handly Delete method.
精彩评论