1
我正在嘗試創建一個持久性cookie。這裏是代碼:使用System.Windows.Application.SetCookie創建持久性cookie失敗?
string expires = string.Format("{0} GMT", DateTime.Now.AddHours(1).ToString("ddd, dd-MMM-yyyy HH:mm:ss"));
string newCookie = string.Format("Cookie1=ValueToStore; expires={0}", expires);
Uri location = new Uri("http://www.mysite.com/Application");
System.Windows.Application.SetCookie(location, newCookie);
string theSetCookie = System.Windows.Application.GetCookie(location);
字符串theSetCookie
應該包含cookie中的所有數據,不是?但它只包含Cookie1=ValueToStore;
。我錯過了什麼?爲什麼沒有到期日,並將其作爲持久性cookie?
注:我使用的Internet Explorer 9在Windows 7
http://msdn.microsoft.com/en-us/library/system.windows.application.setcookie.aspx – makim