http basic authentication “log out”

前端 未结 8 1302
悲&欢浪女
悲&欢浪女 2020-11-28 04:23

HTTP basic authentication credentials are stored until the browser is closed, but is there a way to remove the credentials before the browser is closed?

I read about

8条回答
  •  遥遥无期
    2020-11-28 04:35

    What has worked for me in Chrome (Version 66) is to send an Ajax request to an URL that returns 401. That way the basic authentication cache seems to be cleared.

    var xhttp = new XMLHttpRequest();
    xhttp.open("GET", "/url_that_returns_401", true);
    xhttp.send();
    

提交回复
热议问题