cookie的到期日期与浏览器不同 [英] cookie expiry date different between browser

查看:134
本文介绍了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,它们各自保留单独的副本。

IE保留一个文件夹: C:\Documents and Settings \< user name => \本地设置 - 这里有很多单独的文件。

Firefox和chrome使用(单独)SqLite数据库。 />


因此,Chrome设置的Cookie的到期日期将不会被Chrome认可 - 它甚至不会看到它。
The browsers do not share cookies, they each keep separate copies.
IE keeps a folder: C:\Documents and Settings\<user name="">\Local Settings - this is full of separate files.
Firefox and chrome use (separate) SqLite databases.

As a result, the expiry date of a cookie set by IE will not be honoured by Chrome - it doesn't even look at it.


这篇关于cookie的到期日期与浏览器不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆