Page 1 of 1

PHP_AUTH_USER and PHP_AUTH_PW

Posted: Fri Aug 01, 2003 9:09 pm
by Gen-ik
Is it possible to set and unset the $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] manually without the use of the prompt?

Let's say I have a protected folder with a username and password attached to it (obviously).. and during the execution of a php page I wanted to set the AUTH_USER and AUTH_PW to access the folder, include a file, and then unset the AUTH_USER and AUTH_PW.

Is this possible or does it all have to be done before any header info is sent?

Posted: Sat Aug 02, 2003 11:23 am
by Kriek
You cannot unset authentication variables because they are stored with the client.

Code: Select all

<a href="/index.php" onclick="
document.execCommand('ClearAuthenticationCache');
alert('You are now logged out!');
">Log Me Out</a>
You can however send HTTP headers which tell the browser that it should delete the credentials.

Posted: Sat Aug 02, 2003 1:00 pm
by Gen-ik
Ahh.. thanks for that. That's one side of the problem sorted out :)

All I need to do now is work out how to actually set the username and password without the standard pop-up prompt.... the search continues.