我使用JavaScript函數來存儲的cookie:C#Asp.net得到Cookie的到期時間在JavaScript中設置總是返回01.01.0001
createCookie("teaser", "teaser", 7);
function createCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
}
document.cookie = name + "=" + value + expires + "; path=/";
return value;
}
當我檢查cookies在我的瀏覽器傳情的Cookie有效期正確設置: 25. oktober 2011 16:12:17
但是,當在C#中我去獲取該值,到期日期設置爲01.01.0001。
var cookie = Request.Cookies["teaser"];
if (cookie != null && teaserList.Count() > 0)
{
cookie.Expires is 01.01.0001
任何線索?