How to log out user from web site using BASIC authentication?

后端 未结 22 1947
感情败类
感情败类 2020-11-22 04:00

Is it possible to log out user from a web site if he is using basic authentication?

Killing session is not enough, since, once user is authenticated, each request co

22条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 04:36

    function logout() {
      var userAgent = navigator.userAgent.toLowerCase();
    
      if (userAgent.indexOf("msie") != -1) {
        document.execCommand("ClearAuthenticationCache", false);
      }
    
      xhr_objectCarte = null;
    
      if(window.XMLHttpRequest)
        xhr_object = new XMLHttpRequest();
      else if(window.ActiveXObject)
        xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
      else
        alert ("Your browser doesn't support XMLHTTPREQUEST");
    
      xhr_object.open ('GET', 'http://yourserver.com/rep/index.php', false, 'username', 'password');
      xhr_object.send ("");
      xhr_object = null;
    
      document.location = 'http://yourserver.com'; 
      return false;
    }
    

提交回复
热议问题