DateTime expries=DateTime.UtcNow+TimeSpan.FromDays(15); //設置保存有效天數
string cookie=string.Format("{0}={1};expries={2}",txtId1.Text,txtPassword1.Password,expries);
HtmlPage.Document.SetProperty("Cookie", cookie);
調用
private void _getCookie() {
string[] cookies = HtmlPage.Document.Cookies.Split(';');
foreach (string str in cookies) {
string[] keyValues = str.Split('=');
if (keyVlues.Length == 2) {
this.txtId1.Text = keyValues[0];
this.txtPassword1.Password = keyValues[1];
return;
}
}
}