Heim  >  Fragen und Antworten  >  Hauptteil

javascript – Der über document.cookie in js erhaltene Inhalt ist unvollständig

Der über document.cookie in js erhaltene Inhalt ist unvollständig!
Sie können das vollständige Cookie im Cookie in der Browseranwendung sehen und einzelne Felder können nicht über document.cookie abgerufen werden.
Gibt es eine andere Möglichkeit, es zu bekommen? ?
Bildbeschreibung

天蓬老师天蓬老师2711 Tage vor622

Antworte allen(4)Ich werde antworten

  • PHP中文网

    PHP中文网2017-05-19 10:42:18

    问题描述中所说的不能读到的Cookie内容应该被设置成了 HttpOnly, 即客户端脚本无法读取,只能从服务端读取和操作。

    设置 HttpOnly 的作用就在于通过阻止 JS 读取 Cookie 来 防止XSS 攻击。

    除了通过浏览器插件的方式(浏览器为其提供了接口),使用客户端脚本是基本0可能的。

    Antwort
    0
  • PHP中文网

    PHP中文网2017-05-19 10:42:18

    看一下后面Cookies里有个http,获取不到的应该是http only的,前端无法获取,只能通过http请求获取和操作

    Antwort
    0
  • PHP中文网

    PHP中文网2017-05-19 10:42:18

    cookie体积有限,不同浏览器有区别,现在一般推荐用localstorage

    Antwort
    0
  • 黄舟

    黄舟2017-05-19 10:42:18

    虽然HttpOnly的cookie无法使用脚本查看, 但是chrome扩展是可以查看的.
    安装这个插件: EditThisCookie 后
    可以查看所有cookie内容, 测试时特别有效.

    Antwort
    0
  • StornierenAntwort