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 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记