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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题