• 响应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



  • 相关阅读:
    数据库语句
    Java类和数据结构中常用的方法
    java知识点
    JVM相关知识
    Java实现三种常用的查找算法(顺序查查找,折半查找,二叉排序树查找)
    SharedPreference作用及数据操作模式
    Java实现7种常见的排序算法
    钱多多软件制作03
    钱多多软件制作02
    钱多多软件制作01
  • 原文地址:https://www.cnblogs.com/yfceshi/p/7048021.html
Copyright © 2020-2023  润新知