HTTP基本身份验证注销

问题描述:

我的服务器正在运行Apache,我使用.htaccess进行基本身份验证.但是,我希望我的用户能够通过按钮取消身份验证(注销).有可能并且如何做到这一点?

My server is running Apache and I used .htaccess for my basic auth. However, I want my users be able to cancel the auth (log out) with a button. Is it possible and how to do that?

基本身份验证不用于管理注销.如果您想这样做,则需要执行以下操作:

Basic Auth is not designed to manage log-out. If you would like to do it then you need to do the following:

1)在页面上添加一个注销按钮.

1) Add a logout button to your page.

2)当用户单击注销按钮时,将空白用户名/密码发送到与正常登录情况相同的URL.

2) When user click on the log-out button send a blank username/password to the same URL as in case of normal log-in.

3)在响应中,您发送回您已成功注销"页面.

3) In the response you send back a "You have successfully logged out" page.

原来的凭证将被空的(错误的)凭证覆盖.

The original credentionals will be will overwriten with the empty (wrong) one.

希望对您有帮助.