문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| python:django:csrf [2025/04/15 10:05] – 바깥 편집 127.0.0.1 | python:django:csrf [2025/08/14 12:53] (현재) – taekgu | ||
|---|---|---|---|
| 줄 2: | 줄 2: | ||
| CSRF를 이용하여 시스템을 보호하는 것이 완전하지는 않지만 해주어야 하는군요. | CSRF를 이용하여 시스템을 보호하는 것이 완전하지는 않지만 해주어야 하는군요. | ||
| + | <code html> | ||
| + | < | ||
| + | {% csrf_token %} | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | function getCookie(name) { | ||
| + | let cookieValue = null; | ||
| + | if (document.cookie && document.cookie !== '' | ||
| + | const cookies = document.cookie.split(';' | ||
| + | for (let i = 0; i < cookies.length; | ||
| + | const cookie = cookies[i].trim(); | ||
| + | // Does this cookie string begin with the name we want? | ||
| + | if (cookie.substring(0, | ||
| + | cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | return cookieValue; | ||
| + | } | ||
| + | const csrftoken = getCookie(' | ||
| + | </ | ||