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

后端 未结 22 1781
感情败类
感情败类 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:53

    Here's a very simple Javascript example using jQuery:

    function logout(to_url) {
        var out = window.location.href.replace(/:\/\//, '://log:out@');
    
        jQuery.get(out).error(function() {
            window.location = to_url;
        });
    }
    

    This log user out without showing him the browser log-in box again, then redirect him to a logged out page

提交回复
热议问题