zoukankan      html  css  js  c++  java
  • 浅谈Js 操作Cookie,以及HttpOnly 的限制

    . Js 操作 Cookie.

    一般来说,只有服务器操作Cookie 才能保证一些必要的安全。但有时候,可能需要前端来增删改查 Cookie, 这个时候咱们的主角出现了——HttpOnly(๑•̀ㅂ•́) ✧.

    HttpOnly: HttpOnly is an additional flag included in a Set-Cookie HTTP response header. Using the HttpOnly flag when generating a cookie helps mitigate the risk of client side script accessing the protected cookie (if the browser supports it).

    来着谷歌翻译:

    HttpOnly是包含在Set-Cookie HTTP响应头文件中的附加标志。生成cookie时使用HttpOnly标志有助于降低客户端脚本访问受保护cookie的风险(如果浏览器支持)。

    这个意思就是说,如果某一个Cookie 选项被设置成 HttpOnly = true 的话,那此Cookie 只能通过服务器端修改,Js 是操作不了的,对于 document.cookie 来说是透明的。话不多说,直接上图:



    image


    console里面输入

    document.cookie
    "wd=1922x912; c_user=1201711570"

    可以看到只能看到非httpOnly的

  • 相关阅读:
    Fluxbox 1.0 RC 2
    Cairo 1.2.0
    Transmission 0.6.1
    Xara LX Xtreme 0.5 Rev1175
    Totem 1.4.2
    ImageMagick 6.2.81
    恢复 Firefox 和 Thunderbird 图标
    Conky 1.4.2
    BitTorrent 4.20.0
    Geany 疾速简便的集成启示情况
  • 原文地址:https://www.cnblogs.com/cute/p/12987687.html
Copyright © 2011-2022 走看看