响应http报文中的Date属性与cookie过期时间的关系

今天在测试.net时,发现一个莫名其妙的问题:cookie老是保存不到浏览器端;

经过仔细的比对成功与不成功的报文,竟然无意中发现好像Date与它有关系,这太让我意想不到了,从来不知道cookie保存还要考虑报文中的date

而不是cookie的过期日期设置即可,竟然它的过期时间基点是date,而非浏览器边的客户机器时间优先?


关于报文的date时间是cookie过期时间起算点的验证代码如下,php的


header('Date: Mon, 17 Mar 2015 05:34:54 GMT');//强制修改响应时间为当天的后一天,正常的时间点应该是当前
setcookie('a',rand(),time() + 3600);//cookie一个小时后才过期


这个代码会发现cookie没有被保存在浏览器中,因为浏览器认为cookie相对date而言,已经过期了,所以没有保存,

但是按照我的理解,cookie起算点应该是客户机的时间为准呀?

所以,确实不知http 属性的date还有这样的作用.



经过同事的努力,竟然发现这是iis的一个bug"上去了后,俺不想下来了";

来自http://serverfault.com/questions/217343/date-header-returned-by-iis7-is-wrong


This appears to be a known issue and frequently found on virtual machine due to time sync feature. You may need to restart HTTP service on IIS6 to recover the behavior. Please refer to the content below:

Problem Description

W3SVC logs show incorrect time - stuck on the same time 2007-11-04 04:56:06

REPRO STEPS

  1. Changed the system time to a future time (e.g. 11th May 2020)
  2. Browsed any site - verified the log file created in the new date/time
  3. Changed the system time to be correct (today's date and time)
  4. Now, browsed any website and saw that the time on the log files is now stuck on 11th May 2020's time

RESOLUTION

  • net stop http
  • net start w3svc

OR

  • net stop http
  • net start http
  • iisreset

You must restart the http service whenever you change the date in the server.

Verified in the code and confirmed that this is by design and you need to follow the above steps to make IIS logging the correct time.

I hope the information helps.

Source: http://www.eggheadcafe.com/software/aspnet/31164622/wrong-date-and-time-in-iis-log-file.aspx



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值