diff --git a/js/headfoot.js b/js/headfoot.js
index a1aecda0d2abe814e00e0e53a10639b411e66cc7..cf861a46357e628e6b70fcf2937c62182c277579 100755
--- a/js/headfoot.js
+++ b/js/headfoot.js
@@ -10,7 +10,6 @@ function prependChild(parent,child){
     parent.insertBefore(child, parent.childNodes[0]);
 }
 
-    console.log(document.getElementById('loginswitch').getAttribute('authenticated'));
 function userAuthenticated(){
     let params = new URLSearchParams(window.location.search);
     if(params.get('isAuthenticatedUser')){
@@ -21,6 +20,18 @@ function userAuthenticated(){
         return false;
     }
 }
+
+
+function sendRequest(URL){
+    let xhr = new XMLHttpRequest();
+    xhr.open("POST", URL, true);
+    let token = $("meta[name='_csrf']").attr("content");
+    //Send the proper header information along with the request
+    xhr.setRequestHeader('X-CSRF-TOKEN', token);
+    xhr.send();
+}
+
+
 /* function head()
  * creates header and prepends it to the documents body
  */
@@ -95,7 +106,8 @@ function head(){
                 headlink.innerHTML="Account";
                 headlink.href="/account/";
             }else if(document.getElementById('loginswitch').getAttribute('authenticated') == '2'){
-                headlink.href="./logout";
+                headlink.onclick="sendRequest('./logout');";
+                headlink.href="#";
                 headlink.innerHTML="Logout";
                 
             }