zoukankan      html  css  js  c++  java
  • 响应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



  • 相关阅读:
    009-LSTM网络-长短记忆网络
    008---递归神经网络-RNN
    007-卷积神经网络03-前向传播-反向传播
    006-卷积神经网络02-池化层,全连接层
    005-卷积神经网络01-卷积层
    004-神经网络
    003-神经网络基础-最优化,前向传播,反向传播
    002-神经网络基础-得分函数,SVM损失函数,正则化惩罚项,softmax函数,交叉熵损失函数
    001-神经网络基础-K近邻算法
    DBSCAN聚类算法
  • 原文地址:https://www.cnblogs.com/yfceshi/p/7048021.html
Copyright © 2011-2022 走看看