无法从Cookie读取JSESSIONID

时间:2020-04-06 11:08:54

标签: javascript cookies iframe jsessionid

我对Web开发非常陌生,希望有人能提供帮助。

我正在尝试使用JavaScript从Cookie中读取JSESSIONID,并将其发送给iframe的父级。来自孩子的代码如下所示(感谢David Walsh的示例):

<script>
    setInterval(function() {
    // Send the message "Hello" to the parent window
    parent.postMessage("Hello","http://127.0.0.1:5500");

    // Send Cookies (with JSESSIONID) to the parent window      
    var decodedCookie = decodeURIComponent(document.cookie);
    parent.postMessage(decodedCookie,"http://127.0.0.1:5500");
    },1000);    
</script>

该代码在发送“ Hello”和Cookie的一部分(而不是JSESSIONID)时起作用。

当我在Firefox中使用Storage Inspector并将HttpOnly设置为“ false”时,我可以在cookie中看到JSESSIONID并读取该值。

希望有人可以解释它并作为解决方案。

[编辑]

JSESSIONID位于根目录下的路径中。

0 个答案:

没有答案