PHP_AUTH_USER and PHP_AUTH_PW

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

PHP_AUTH_USER and PHP_AUTH_PW

Post 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?
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post 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.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post 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.
Post Reply