문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판 | |||
| python:django:csrf [2025/08/14 12:46] – taekgu | python:django:csrf [2025/08/14 12:53] (현재) – taekgu | ||
|---|---|---|---|
| 줄 8: | 줄 8: | ||
| < | < | ||
| </ | </ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | 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(' | ||
| </ | </ | ||