响应http报文中的Date属性与cookie过期时间的关系
2017-06-19 11:47
381 查看
今天在測试.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:
W3SVC logs show incorrect time - stuck on the same time 2007-11-04 04:56:06
Changed the system time to a future time (e.g. 11th May 2020)
Browsed any site - verified the log file created in the new date/time
Changed the system time to be correct (today's date and time)
Now, browsed any website and saw that the time on the log files is now stuck on 11th May 2020's time
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
经过细致的比对成功与不成功的报文,居然无意中发现好像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
Changed the system time to a future time (e.g. 11th May 2020)Browsed any site - verified the log file created in the new date/time
Changed the system time to be correct (today's date and time)
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 httpnet 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
相关文章推荐
- 响应http报文中的Date属性与cookie过期时间的关系
- 服务端删除cookie: 响应头设置过期的时间+无效的cookie值
- ahjesus在asp.net中还可以通过设置HttpCookie对象的过期时间为DateTime.MinValue来指定此Cookies为跟随浏览器生效
- HTTP报文解析,请求报文头属性、响应码
- Java web程勋中cookie 不能写入HTTPOlny属性 (跨域问题)
- 如何设置cookie的过期时间
- JS读写Cookie以及设置过期时间
- HttpWebRequest..::.CookieContainer 属性
- 本机时间设置错误导致Cookie过期
- cookie的httponly属性
- 使用Filter统计Java(J2EE)的web程序http请求响应时间
- 使用Filter统计Java(J2EE)的web程序http请求响应时间
- Ajax XMLHttp GET HTML 如何设定允许的服务器响应时间?
- JS去空格、IFrame提示信息做后台操作、Cookie存值获取累加,调整过期时间。
- 理解http响应头中的Date和Age
- ASP.NET HttpContext的时间戳属性
- 用pycurl监控http响应时间
- cookie 的过期时间
- responseText属性,XMLHttpRequest,responseText,XML响应,XMLHttpRequest属性,
- Page标签 ContentType 属性指定响应的 HTTP 内容类型