简体   繁体   中英

how to read HttpOnly cookies using JavaScript?

I already tried document.cookie and it didn't work. I tried researching but I couldn't find a solution.

You can't - thats the whole point of HttpOnly

A cookie with the HttpOnly attribute is inaccessible to the JavaScript Document.cookie API; it is sent only to the server. For example, cookies that persist server-side sessions don't need to be available to JavaScript, and should have the HttpOnly attribute. This precaution helps mitigate cross-site scripting (XSS) attacks

Info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies

If your cookie does not contain sensitive info (such as a server-side session) then it should not be marked HttpOnly !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM