简体   繁体   English

C#asp.net:Chrome Chrome中的截止日期

[英]C# asp.net: Cookie Expiration date in Chrome

I'm having an issue with the Expiration date of a cookie in C# when in chrome. 我在使用Chrome时在C#中的Cookie的截止日期有问题。

Here is the code I'm using: 这是我正在使用的代码:

public static void createCookie(Users u, DateTime expirationDate)
{
    HttpCookie loginCookie = new HttpCookie("cookie");
    loginCookie.Value = "somevalue";
    loginCookie.Expires = DateTime.UtcNow.AddDays(1d);
    HttpContext.Current.Response.Cookies.Add(loginCookie);
}

I've run this code through Fiddler and it does return the correct Expiration Date. 我通过Fiddler运行此代码,它确实返回了正确的到期日期。 The cookie's expiration date is also correct in Firefox and IE9 However, when I run this in chrome the expiration date is always set to: Sun, 07 Dec 1969 03:28:36 GMT 在Firefox和IE9中,cookie的到期日期也是正确的但是,当我在chrome中运行时,到期日总是设置为:Sun,19 Dec 1969 03:28:36 GMT

Always at 3:28:36 GMT it never changes. 总是在格林威治标准时间3:28:36它永远不会改变。 Any idea on why this is happening would be greatly appreciated. 任何关于为什么会发生这种情况的想法将不胜感激。 Thanks! 谢谢!

I've also tried to set the expiration date using: DateTime.Now.AddDays(1d) with the same result. 我还尝试使用:DateTime.Now.AddDays(1d)设置过期日期,结果相同。

It's a bug in the current version of chrome, it's the displaying of the expiration date that is wrong, not the actual expiration, the value you have set will be honored by chrome! 这是当前版本的chrome中的一个错误,它是显示错误的到期日期,而不是实际的到期日期,您设置的值将受到Chrome的尊重!

Here's a link to the bug which has been fixed in their nightly builds (Verified as Fixed with 20.0.1132.7 (Official Build 136817)) : http://code.google.com/p/chromium/issues/detail?id=125546 这是一个已修复的夜间版本中的错误链接(已验证为20.0.1132.7(官方版本136817)): http//code.google.com/p/chromium/issues/detail? id = 125546

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM