本文介绍了cookie的到期日期与浏览器不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HttpCookie hc_username = new HttpCookie("userID");
hc_username.Value = "0001";
System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("nl-NL");
DateTime dt2 = DateTime.Parse("12/12/2013 01:40:00 PM", cultureinfo);
hc_username.Expires = dt2.AddSeconds(30);
Response.Cookies.Add(hc_username);
当我通过Internet Explorer / Firefox打开时,Cookie已过期 12/12/2013 01:40:30 PM正如预期的那样。
但是当我通过谷歌浏览器打开时,过期的日期显示13/12/2013 04:40:38 GMT,以及即使我已经等了30分钟,饼干也不会过期。
但如果我写:
When i open via Internet explorer/Firefox, the cookies expired on "12/12/2013 01:40:30 PM" as expected.
but when i open via google chrome, the expired date display "13/12/2013 04:40:38 GMT", and the cookies wont expired even i already waited for 30min.
but if i write:
Response.Write("Expiry: " + hc_username.Expires + "<br>");
显示12/12/2013 01:40:30 PM这在google chrome中是正确的
有谁知道如何解决这个问题?这是来自chrome的错误吗?
it shows "12/12/2013 01:40:30 PM" which is correct at google chrome
anyone know how to solve this? is this a bugs from chrome?
推荐答案
这篇关于cookie的到期日期与浏览器不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!