With my current understanding, I am not completely satisfied with the established answer.
You can find my version here .
To summarize, CSRFCookie is “safe,” in the sense that an attacker cannot gain access to it because of policies of the same origin. The browser will automatically send this value. Now your form should also send this value (for example, in a hidden field). This means that your form must know this value, and it can receive it from the cookie.
An attacker cannot obtain a token from a cookie and, therefore, cannot fake malicious code containing a token.
What is important, in the end, the user can send the csrf token and that the server can check it. Using a cookie is a convenient way to do this, but it can be implemented in different ways (for example, a server can save CSRF tokens for each session, for example).
I am not an expert, but as I understand it. Hope this helps.
source share