HTTP AUTH logout method
Submitted by Jozsef on March 12, 2013 - 2:27pmThis code cause logout feeling for your user. The browser will ask again the username and password.
<?php
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.