douji1853 2011-11-14 03:12
浏览 171
已采纳

Chrome忽略跨域Cookie过期

On domain 1, I have a form that posts to domain 2

<form method="post" action="http://domain2.com/result.php">

The script result.php on domain 2 sets a cookie on domain 2 that is supposed to last until the year 2038.

setcookie('test', 'val', 2147485540, '/', '.domain2.com', false);

The cookie is being stored, but on Chrome, the expiration is set to "When I close my browser" (in other words, 0). On Firefox the expiration is set correctly.

Is there any way around this or is this a Chrome security setting regarding cross-domain posting that I'll just have to live with?

  • 写回答

1条回答 默认 最新

  • dte49889 2011-11-14 03:36
    关注

    It has to do with the expiration, not the domain. You are using 2147485540 which is equivalent to Tue, 19 Jan 2038 03:45:40 Some browsers have trouble with dates beyond 03:14:07 UTC on Tuesday, 19 January 2038.

    This will work:

    setcookie('test', 'val', gmmktime(3, 14, 7, 1, 19, 2038), '/', '.domain2.com', false);
    

    This won't:

    setcookie('test', 'val', gmmktime(3, 14, 8, 1, 19, 2038), '/', '.domain2.com', false);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失