Silverlight读取与设置Cookies
设置Cookie
DateTime expire = DateTime.UtcNow + TimeSpan.FromDays(30);string cookie = string.Formate("{0}={1},expires={2}",key,value,expire)HtmlPage.SetProperty("cookie",cookie);
读取Cookie
由于读取到的Cookie是一个集合,所以需要遍历它。
string result="";string[] cookies = HtmlPage.Document.Cookies.Split(';');foreach(string cookie in cookies){string cooArr = cookie.split('=');if(cooArr.Length >=2){ result = cooArr[1];}
}
posted on 2012-06-17 13:14 jayce80 阅读(...) 评论(...) 编辑 收藏