【问题标题】:What is the Cookie Domain in a Cross-domain PHP Call by JavaScript?JavaScript 跨域 PHP 调用中的 Cookie 域是什么?
【发布时间】:2015-12-22 17:30:28
【问题描述】:

如果我在域 here.com 中的页面中有 JavaScript 调用驻留在域 there.com 下的 PHP,那么该 PHP 是否访问 here.com 或 there.com 中的 cookie?包装 IFRAME 会有所不同吗?

【问题讨论】:

    标签: javascript php iframe cookies cross-domain


    【解决方案1】:

    cookie 域是 HTTP 请求的目标:there.com。包裹在 iframe 中没有任何区别。

    【讨论】:

    • 这就是我的想法,但是当我从 here.com 调用我的远程 PHP 以获取域 there.com 中名为 auth 的 cookie 时,报告的值是“”而不是“499d73a09e0”,存储在 auth 中的值。当在 there.com 调用相同的 PHP 时,该值正确返回为“499d73a09e0”。我错过了什么?
    • 您是否尝试从 javascript 访问 cookie?如果是这样,请记住任何标记为 HttpOnly 的 cookie 都将无法被 javascript 读取。
    • 我创建的第二个cookie,命名为hash2,HttpOnly为false,仍然像第一个cookie一样读取空白,命名为hash:setcookie("hash",$hash,time()+3600*24*365 ,"/") setcookie("hash2",$hash,time()+3600*24*365,"/",null,false,false).我还缺少什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    • 2020-12-20
    相关资源
    最近更新 更多