3 ms·
Another solution is to set the csrf token as two cookies: one that can be read by js via document.cookie, and another that is httponly. Js is then responsible
by dgoldstein0 7y ago
Another solution is to set the csrf token as two cookies: one that can be read by js via document.cookie, and another that is httponly. Js is then responsible for including the csrf token in any requests (including forms). This avoids crime/breach issues because cookies are part of http headers, which are "compressed" with hpack in http2. Hpack is basically "send it once and reference the last value many times".
Of course there are a few more details to getting this right (such as tying csrf & auth cookies) and it doesn't hurt to also add samesite to the mix.