diff --git a/js/headfoot.js b/js/headfoot.js index 2b39c6e54e1f4751c5c0822c3bbf12c32209b126..6c6b883758e68fa78ce6b872d0b270030aca057c 100755 --- a/js/headfoot.js +++ b/js/headfoot.js @@ -22,10 +22,23 @@ function userAuthenticated(){ } +function readCookie(name) { + var nameEQ = encodeURIComponent(name) + "="; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) === ' ') + c = c.substring(1, c.length); + if (c.indexOf(nameEQ) === 0) + return decodeURIComponent(c.substring(nameEQ.length, c.length)); + } + return null; +} + function sendRequest(URL){ let xhr = new XMLHttpRequest(); xhr.open("POST", URL, true); - let token = $("meta[name='_csrf']").attr("content"); + let token = readCookie("XSRF-TOKEN"); //Send the proper header information along with the request xhr.setRequestHeader('X-CSRF-TOKEN', token); xhr.send();