HTTP AUTH logout method

This code cause logout feeling for your user. The browser will ask again the username and password.

  header('WWW-Authenticate: Basic realm="protected area"');
  header('HTTP/1.0 401 Unauthorized');

I use it with a logout controller, that set a session variable to true and redirect the request to the home page. And the home page check this session variable, and if it true, it sends these headers and set back the session variable to null.

This is my method, but you can use this HTTP auth logout method as you like.


Read more posts by this author.